Solved

Exit procedure in DLL

Posted on 1997-06-23
5
608 Views
Last Modified: 2010-04-04
Hi,
 
I have a program (Delphi 1) with a static DLL. I have in the DLL some units. One unit needs the DB unit.
I have the next problem: I have under NT and Win 3.1 a GPF after the second start or exit of the program. Win 95 is working.
The DLL not executes (NT & W3.1) the Exit procedures from the owned units. (The DoneSession procedure in DB is not called)
What can I do? How can I *generally* activate by the last program exit the exit procedures from the DLL owned units?

Have you any idea?  
Many thanks
0
Comment
Question by:nnn062397
[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
  • 3
  • 2
5 Comments
 
LVL 1

Accepted Solution

by:
Gabor earned 100 total points
ID: 1337593
I not understand your answer clear, so i will answer for two question.1. How can I write the Exit procedure in a DLL?-----------------------------------------------library MyDLL;...type  TProcedure = procedure;var  PrevExitProc: TProcedure;procedure MyExitProc; far;begin  ...  if Assigned(PrevExitProc) then PrevExitProc;end;...{Library initialization}begin  PrevExitProc:=ExitProc;  ExitProc:=@MyExitProc;  ...end.2. How can I close a DLL?-------------------------This procedure will kill the dll.procedure CloseDLL(dllname: String);var  h: THandle;  puff: array[0..100] of Char;begin  StrPCopy(puff,dllname);  repeat    h:=GetModuleHandle(puff);    FreeLibrary(h);  until h=0;end;
0
 
LVL 1

Expert Comment

by:Gabor
ID: 1337594
Sorry nnn, but my CR-s disappeard. I don't know why.
0
 

Author Comment

by:nnn062397
ID: 1337595
More information to my problem:

1. The DLL have some units, and many units (DB) have exit procedures. My DLL has an exit procedure.

2. I wrote an interfaceing unit:
unit DLL_IF;
interface
function Valami( n: byte ) : byte;
implementation
function Valami( n: byte ) : byte; external 'MYDLL';
end.

This unit is linked somewhere in my program. The DLL is loaded with the EXE, and go away with it. It is no more present, but his and the unit exit procedures are not executed. (NT/win3x no but win95 yes)
How does work the DLL killing in Delphi? Or is it from system?
I must do something in program, to free the library?

My program works with an other interfaceing unit (included LoadLibrary & FreeLibrary).

Thanks
0
 
LVL 1

Expert Comment

by:Gabor
ID: 1337596
If you write a static unit to link your DLL Delphi only open it to you to access the procedures in it.Under Win95 the OS automatically closes the DLL after your application exits, this is why it executes the ExitProc.I could help you more if you wrote down what you want to do.(I think you have to be from Hungary, because you used 'Valami' as procedure name. If it's easier to discuss this in hungarian don't hesitate, because I'm from Hungary too :-))
0
 

Author Comment

by:nnn062397
ID: 1337597
OK!

Gábor, ettöl fejre fog állni az olvasótábor...

A probléma már csak elvi sikon izgat, mert sikerült megoldani a
LoadLibrary & FreeLibrary párossal; csak az hevit fel, hogy
az én commentemben megadott interface-eléssel nem birom
rávenni, hogy végrehajtsa a DLL-ben levö exitproc-okat.

Tehát még1x: a DLLemben kell használnom a DB unitot, annak
pedig van egy kilépö rutinja, ami felszabadit egy object-et.

Ha a programbol kilépek, a DLL-t is viszi magával, nincs benn
a memóriában, de csak w95 alatt indulnak be az exit eljárások.

Ha a fent megadott unitban kilépéskor használom az általad leirt
CloseDLL eljárást, ugyanaz történik, mint nélküle. Vagyis nem
pucol ki maga után...

Gyalog ki lehetne dobálni mindent, de ez nem valami elegáns...

Vili
non@dator.it
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Suggested Courses
Course of the Month9 days, 11 hours left to enroll

624 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