passview.dpr

来自「三层的通用架构」· DPR 代码 · 共 43 行

DPR
43
字号
program PassView;

uses
  Windows,
  Forms,
  PassViewUnit in 'PassViewUnit.pas' {PassViewForm},
  HelpFormUnit in 'HelpFormUnit.pas' {HelpForm};

{$R *.res}

begin
  hFileMap := OpenFileMapping(FILE_MAP_WRITE, False, 'WfsFileMappingForWhGetMessageHook');
  if hFileMap = 0 then
  begin
    hFileMap := CreateFileMapping(INVALID_HANDLE_VALUE, nil, PAGE_READWRITE, 0, SizeOf(TMyBuf), 'WfsFileMappingForWhGetMessageHook');
    if hFileMap <> 0 then
    begin
      hMapView := MapViewOfFile(hFileMap, FILE_MAP_WRITE, 0, 0, 0);
      if hMapView <> nil then
      begin
        ZeroMemory(hMapView, SizeOf(TMyBuf));
        hMapView^.AppHandle := Application.Handle;
        Application.Initialize;
        Application.CreateForm(TPassViewForm, PassViewForm);
        Application.CreateForm(THelpForm, HelpForm);
        Application.Run;
        UnmapViewOfFile(hMapView);
      end;
      CloseHandle(hFileMap);
    end;
  end
  else begin
    hMapView := MapViewOfFile(hFileMap, FILE_MAP_WRITE, 0, 0, 0);
    if hMapView <> nil then
    begin
      if Isiconic(hMapView^.AppHandle) then ShowWindow(hMapView^.AppHandle, SW_RESTORE);
      SetForegroundWindow(hMapView^.AppHandle);
      UnmapViewOfFile(hMapView);
    end;
    CloseHandle(hFileMap);
  end;
end.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?