[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Easy question about dll's

Posted on 2002-03-08
4
Medium Priority
?
242 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 100 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses
Course of the Month18 days, 10 hours left to enroll

834 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