Solved

Easy question about dll's

Posted on 2002-03-08
4
233 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: 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

Suggested Solutions

Title # Comments Views Activity
Print Graphic and Text to Epson TM-T88v 12 478
Dev Express grid collapse 2 48
Tidtcpserver listening on multiports? 1 46
Delphi, TImage, Png 2 32
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…

730 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