Solved

Easy question about dll's

Posted on 2002-03-08
4
232 Views
Last Modified: 2010-04-05
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;
0
Comment
Question by:trunin
4 Comments
 
LVL 17

Expert Comment

by:Wim ten Brink
ID: 6850270
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.
0
 
LVL 8

Accepted Solution

by:
TOndrej earned 50 total points
ID: 6850348
The help says "Inside a DLL, you can use the DLLProc variable instead."
But I think I've heard that there's a bug in the RTL which causes that your libraryproc is never called with DLL_PROCESS_DETACH (or was it DLL_THREAD_DETACH?).
You'd better test it for yourself.
Also try finalization sections, as Workshop_Alex suggested (Hi, Alex! :-)
0
 
LVL 1

Author Comment

by:trunin
ID: 6850403
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.
0
 
LVL 3

Expert Comment

by:cubud
ID: 6850704
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

0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Path  to current project in Delphi. 2 92
Multi-layered image in FireMonkey 9 48
MS Access from Delphi 31 60
FMX TEdit KeyUp handler detecting  "enter" key 4 13
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question