example.dpr

来自「Delphi Win32核心API参考光盘源码 本书包含了常用的Windows」· DPR 代码 · 共 45 行

DPR
45
字号
library Example;

uses
  SysUtils,
  Classes,
  Windows,
  Dialogs,
  DLLAboutForm in 'DLLAboutForm.pas' {AboutBox};

{the exported functions}
exports
  ShowAboutBox name 'ShowAboutBox';

{the DLL entry point function.  this fires whenever a process or thread
 attaches to the DLL.  if a process has already loaded the DLL, any new
 threads created by the process will automatically attach themselves}
procedure DLLMain(AttachFlag: DWORD);
 begin
   {indicate attachement type}
   case AttachFlag of
     DLL_PROCESS_ATTACH: begin
                           MessageBox(0, 'Process: Attaching' , 'Alert', MB_OK);

                           {this function disables the DLL_THREAD_ATTACH and
                            DLL_THREAD_DETACH notifications. if the following
                            line is commented out, the DLL will recieve
                            the thread attach/detach notification}
                           DisableThreadLibraryCalls(hInstance)
                         end;
     DLL_PROCESS_DETACH: MessageBox(0, 'Process: Dettaching', 'Alert', MB_OK);
     DLL_THREAD_ATTACH:  MessageBox(0, 'Thread: Attaching'  , 'Alert', MB_OK);
     DLL_THREAD_DETACH:  MessageBox(0, 'Thread: Dettaching' , 'Alert', MB_OK);
   end;
end;

begin
  {initialize the DLL entry point function}
  DLLProc := @DLLMain;

  {call the entry point function on DLL initialization}
  DLLMain(DLL_PROCESS_ATTACH);
end.


⌨️ 快捷键说明

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