Solved

Easy question about dll's

Posted on 2002-03-08
4
229 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

758 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now