你查一下DLL入口函数和出口函数的资料,具体我也没用过,这是从D6开发指南的一个例子 library DLLEntryLib; uses SysUtils, Windows, Dialogs, Classes;procedure DLLEntryPoint(dwReason: DWord); begin case dwReason of DLL_PROCESS_ATTACH: ShowMessage('Attaching to process'); DLL_PROCESS_DETACH: ShowMessage('Detaching from process'); DLL_THREAD_ATTACH: MessageBeep(0); DLL_THREAD_DETACH: MessageBeep(0); end; end;begin { First, assign the procedure to the DLLProc variable } DllProc := @DLLEntryPoint; { Now invoke the procedure to reflect that the DLL is attaching to the process } DLLEntryPoint(DLL_PROCESS_ATTACH); end.
library DLLEntryLib;
uses
SysUtils,
Windows,
Dialogs,
Classes;procedure DLLEntryPoint(dwReason: DWord);
begin
case dwReason of
DLL_PROCESS_ATTACH: ShowMessage('Attaching to process');
DLL_PROCESS_DETACH: ShowMessage('Detaching from process');
DLL_THREAD_ATTACH: MessageBeep(0);
DLL_THREAD_DETACH: MessageBeep(0);
end;
end;begin
{ First, assign the procedure to the DLLProc variable }
DllProc := @DLLEntryPoint;
{ Now invoke the procedure to reflect that the DLL is attaching to the
process }
DLLEntryPoint(DLL_PROCESS_ATTACH);
end.