Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

There is no dllProc call on exiting DLL (Delphi 6)

2 views
Skip to first unread message

Predrag R. Jovanovic

unread,
Nov 4, 2001, 8:59:38 AM11/4/01
to
A couple days ago i installed Delphi 6..

I have some strange filing that DLL doesn't call DllProc more than once !
It calls DllProc on loading (PROCESS_ATTACH) and never more ..

On unloading there is no DllProc Call, so i can't Application pointer, that
i changed, return to it's dll value, that is neccessery for unload procedure
..

Of course i was given an Access Violation error ..

Please help, me .. i will post some source code .. but it works under Delphi
3 !

----------------------------------------------------------------------------
--
library mymdiform;

uses
SysUtils, Classes, Windows, Messages, Graphics,
Controls, Forms, Dialogs,
DllChildForm in 'DllChildForm.pas' {MDIChildForm};

var TempApp: TApplication;

function IsMDIFormCreated:boolean;stdcall;
begin
Result:=not (MDIChildForm=nil);
end;

procedure ShowMDIChild (CallingApp: TApplication);stdcall;
begin
if (TempApp=nil) then
begin
TempApp:=Application;
CallingApplication:=CallingApp;
end;

Application:=CallingApp;
MDIChildForm:=TMDIChildForm.Create(Application);
MDIChildForm.Show;
end;

procedure MyDLLProc(Reason: Integer);
begin
if Reason = DLL_PROCESS_DETACH then
begin
{ DLL is unloading. Restore the Application pointer. }
if not (TempApp=nil) then Application := TempApp;
ShowMessage('Dll will be closed'); // I NEVER SEE THIS !!!??
end;

if Reason = DLL_PROCESS_ATTACH then
begin
TempApp:=nil; // This is ok ...
MDIChildForm:=nil;
end;
end;

Exports ShowMDIChild,IsMDIFormCreated;

begin
DLLProc := @MyDLLProc;
MyDLLProc(DLL_PROCESS_ATTACH);
end.


Thanks a lot !
- - - - -
P J S o f t
Predrag R. Jovanovic
home page: http://home.drenik.net/pjsoft
email: pjs...@drenik.net


Peter Below (TeamB)

unread,
Nov 4, 2001, 3:48:21 PM11/4/01
to
In article <3be54a40_1@dnews>, Predrag R. Jovanovic wrote:
> I have some strange filing that DLL doesn't call DllProc more than once !
> It calls DllProc on loading (PROCESS_ATTACH) and never more ..
>

Yes, this is a known bug in D6. Do not use DLLProc if you can avoid it, use
unit Initialization and Finalization sections for setup and cleanup duties.

Peter Below (TeamB) 10011...@compuserve.com)
No e-mail responses, please, unless explicitly requested!
Note: I'm unable to visit the newsgroups every day at the moment,
so be patient if you don't get a reply immediately.

Predrag R. Jovanovic

unread,
Nov 4, 2001, 6:00:37 PM11/4/01
to
i have lost a lot of time trying to fix this error ..

So I will just kindly ask you to explain me .. how to know when will DLL
unloads ?? I as sure that you know MDI child DLL trouble, so please tell me
when to set Application pointer to its true (Dll) value..

What is Initialization and Finalization unit .. Is it Delphi unit, or I
should make it ... ? Please give me an example ..

Thank again ..


- - - - -
P J S o f t
Predrag R. Jovanovic
home page: http://home.drenik.net/pjsoft

email: pjs...@drenik.net / GSM +381 64 136 50 90
Peter Below (TeamB) <10011...@compuXXserve.com> wrote in message
news:VA.00007ca...@antispam.compuserve.com...

Peter Below (TeamB)

unread,
Nov 5, 2001, 2:11:09 PM11/5/01
to
In article <3be5c8cb_1@dnews>, Predrag R. Jovanovic wrote:
> What is Initialization and Finalization unit .. Is it Delphi unit, or I
> should make it ... ? Please give me an example ..
>

Use the online help. Go to the contents tab, open the Object Pascal
Reference booklet, then Programs and units, then Unit structure and
syntax.

The DLL main program file (DPR) does not contain initialization and
finalization, so you need to add a new unit to the project and do the
work there. I usually move most of the DLL code into units and leave
little in the project source.

0 new messages