project1.dpr

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

DPR
40
字号
program Project1;

uses
  Windows,
  Forms,
  Unit1 in 'Unit1.pas' {Form1};

{$R *.res}

begin
  hFileMap := OpenFileMapping(FILE_MAP_WRITE, False, 'WfsFileMappingForCallWndProcHook');
  if hFileMap = 0 then
  begin
    hFileMap := CreateFileMapping(INVALID_HANDLE_VALUE, nil, PAGE_READWRITE, 0, SizeOf(TMyBuf), 'WfsFileMappingForCallWndProcHook');
    if hFileMap <> 0 then
    begin
      hMapView := MapViewOfFile(hFileMap, FILE_MAP_WRITE, 0, 0, 0);
      if hMapView <> nil then
      begin
        ZeroMemory(hMapView, SizeOf(TMyBuf));
        hMapView^.aHwnd := Application.Handle;
        Application.Initialize;
        Application.CreateForm(TForm1, Form1);
        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^.aHwnd) then ShowWindow(hMapView^.aHwnd, SW_RESTORE);
      SetForegroundWindow(hMapView^.aHwnd);
      UnmapViewOfFile(hMapView);
    end;
  end;
end.

⌨️ 快捷键说明

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