Link to home
Start Free TrialLog in
Avatar of gags03
gags03

asked on

Why isn't DLLPROC being called when my DLL is unloaded? in DELPHI 6 only

QUESTION:
Why isn't DLLPROC being called when my DLL is unloaded?

I have this answer, but it do not work well

ANSWER:
Due to RTL changes, the DLLProc was not being called appropriately. This change will fix the change that you may have noticed. Once you have completed the change, you will need to recompile the RTL and copy the new System.dcu into your project directory. Your project will use the newly created System.dcu with the fix included. In System.pas, navigate down to this method @@skipTLSproc.

@@skipTLSproc:

        { Call any DllProc }

        PUSH    ECX
        MOV     ECX,[ESP+8]//Changed from 4 to 8.
        TEST    ECX,ECX
        JE      @@noDllProc
        MOV     EAX,[EBP+12]
        MOV     EDX,[EBP+16]
        CALL    ECX

(I can't do the "make" because I have installed the Update Pack 1)
Avatar of Madshi
Madshi

Can't you add a unit to your dll project and use the unit's finalization part? This is equivalent and worked perfectly fine for me all of the time yet...

Regards, Madshi.
Avatar of gags03

ASKER

Yeah that's right, the finalization work, but ...

I need to used DLLPROC, because I want to use the
DLL_THREAD_ATTACH, DLL_THREAD_DETACH: info ...
Avatar of Wim ten Brink
It can happen that this method isn't called because Windows terminates the DLL the hard way. This always happens if the DLL is a MTS/COM+ library.
DLLPROC is called when the application that uses the DLL closes the DLL gracefully. Which means you have to unload the library when you don't need it anymore. If you don't, the DLL might be killed without notifications.
ASKER CERTIFIED SOLUTION
Avatar of gags03
gags03

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
gags03:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.