We help IT Professionals succeed at work.

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

gags03
gags03 asked
on
Medium Priority
459 Views
Last Modified: 2011-10-03
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)
Comment
Watch Question

Commented:
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.

Author

Commented:
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 ...
Wim ten BrinkSelf-employed developer
CERTIFIED EXPERT

Commented:
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.
Commented:
Thanks all ... With the Update pack 2, the problem is solve
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.

Explore More ContentExplore courses, solutions, and other research materials related to this topic.