trunin
asked on
Easy question about dll's
I need something like "ExitProc" but for dll's, because
"ExitProc should only be used when generating .EXE files."(Delphi help)
There is code that I was created for .exe files.
....
var SaveProc:Pointer;
....
SaveProc := ExitProc;
ExitProc := @MyExitProc
procedure MyExitProc;
begin
ExitProc := SaveProc
....
end;
"ExitProc should only be used when generating .EXE files."(Delphi help)
There is code that I was created for .exe files.
....
var SaveProc:Pointer;
....
SaveProc := ExitProc;
ExitProc := @MyExitProc
procedure MyExitProc;
begin
ExitProc := SaveProc
....
end;
Why not use the finalization part of a unit? Write the DLL code in a seperate unit, not the .dpr file, and add an initialization and a finalization part to it.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi all.
To TOndrej:
I was tested it but when I unload dll then it allways call DLLProc with DLL_PROCESS_ATTACH parameter. :(
TO Workshop Alex:
I will try your idea later.
To TOndrej:
I was tested it but when I unload dll then it allways call DLLProc with DLL_PROCESS_ATTACH parameter. :(
TO Workshop Alex:
I will try your idea later.
procedure LibEntry(Reason: Integer);
begin
if Reason = DLL_THREAD_DETACH then
begin
Do your code here
end;
end;
begin
DllProc := @LibEntry;
end.
http://www.howtodothings.com
begin
if Reason = DLL_THREAD_DETACH then
begin
Do your code here
end;
end;
begin
DllProc := @LibEntry;
end.
http://www.howtodothings.com