library CatchWndMsg; { Important note about DLL memory management: ShareMem must be the first unit in your library's USES clause AND your project's (select Project-View Source) USES clause if your DLL exports any procedures or functions that pass strings as parameters or function results. This applies to all strings passed to and from your DLL--even those that are nested in records and classes. ShareMem is the interface unit to the BORLNDMM.DLL shared memory manager, which must be deployed along with your DLL. To avoid using BORLNDMM.DLL, pass string information using PChar or ShortString parameters. } uses System.SysUtils, System.Classes, Winapi.Windows, WindowCatchWndMsg in 'WindowCatchWndMsg.pas', DefineWndMon in '..\DefineWndMon.pas'; {$R *.res} var WindowActiveHook: TWindowCatchWndMsg = nil; procedure DLLEntryPoint(dwReason: DWORD); begin case dwReason of DLL_PROCESS_ATTACH : begin WindowActiveHook := TWindowCatchWndMsg.Create; end; DLL_PROCESS_DETACH : begin try if Assigned(WindowActiveHook) then begin { if WindowActiveHook.SharedData.IsAvailable then begin case THookState(WindowActiveHook.SharedData.Data.HookState) of hsFree : begin // TSunkTrace.t('WindowActiveHook >>> DLL_PROCESS_DETACH >> HookState = hsFree'); end; hsHooking : // ÀÌ °æ¿ì´Â ¸ÞÀο¡¼­ Á¤½ÄÀ¸·Î DLLÀ» ³»¸°°æ¿ì°¡ ¾Æ´Ï´Ù. ´Ù½Ã ·Îµå ÇÒ¼ö ÀÖ°Ô ÇÑ´Ù. begin // TSunkTrace.t('WindowActiveHook >>> DLL_PROCESS_DETACH >> HookState = hsHooking, RcvWnd = %d', [WindowActiveHook.SharedData.Data.hRcvWnd]); PostMessage(WindowActiveHook.SharedData.Data.hRcvWnd, WM_WNDHOOK_RELOAD, GetCurrentProcessId, GetCurrentThreadId); end; hsReload : begin // TSunkTrace.t('WindowActiveHook >>> DLL_PROCESS_DETACH >> HookState = hsReload'); end; hsFinish : // Á¤»óÀûÀÎ DETACH ÀÛ¾÷À̶ó°í ÆÇ´Ü begin // TSunkTrace.t('WindowActiveHook >>> DLL_PROCESS_DETACH >> HookState = hsFinish'); WindowActiveHook.SharedData.Data.HookState := hsFree; end; end; end; } FreeAndNil(WindowActiveHook); end; except // end; end; end; end; begin DllProc := @DLLEntryPoint; DLLEntryPoint(DLL_PROCESS_ATTACH); end.