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

InitInstance not being called in DLL

340 views
Skip to first unread message

Lawrence A. Latouf

unread,
Jul 7, 1999, 3:00:00 AM7/7/99
to

I have a USRDLL using MFC (dynamically linked).

I have a test driver (MFC APP) which when run with the DLL, InitInstance is
called fine.

Though, the real app is written in Delphi, and when I run with it, my
InitInstance (or ExitInstance for that matter)
doesn't get called.

Am I missing something?


Thanks in advance.

Larry Latouf


Scott Tunstall

unread,
Jul 7, 1999, 3:00:00 AM7/7/99
to
InitInstance() is MFC specific - it belongs to CWinApp class.

An MFC application will call InitInstance() if it exists in the DLL. As
Delphi is not MFC <grin> then it knows nothing about InitInstance and will
treat the DLL like any non-MFC job.

To call InitInstance from your Delphi app. use Win32 call GetProcAddress.

Lawrence A. Latouf wrote in message <3783...@news.greennet.net>...

Scott Tunstall

unread,
Jul 7, 1999, 3:00:00 AM7/7/99
to
This documentation can be found in Infoviewer @:

mk:@ivt:vccore/F26/D29/S28D6.HTM

You can navigate to it from "DLLs: Overview".

Kind of DLL Where to add initialization and termination code
---------------------------------------------------------------------------
-------------


Regular DLL
In the DLL's CWinApp object's InitInstance and ExitInstance.

Extension DLL
In the DllMain function generated by AppWizard.

Non-MFC DLL
In a function called DllMain that you provide.

In Win32, all DLLs may contain an optional entry-point function (usually
called DllMain) that is called for both initialization and termination. This
gives you an opportunity to allocate or release additional resources as
needed. Windows calls the entry-point function in four situations: process
attach, process detach, thread attach, and thread detach.

The C run-time library provides an entry-point function called
_DllMainCRTStartup, and it calls DllMain. Depending on the kind of DLL,
either you should have a function called DllMain in your source code or you
should use the DllMain provided in the MFC library.


--
Scott Tunstall
MFC & COM consultant
FirstTel systems Ltd
Glasgow
Scotland

Tel: 0141 207 3102
Scott Tunstall wrote in message <#yACiQKy#GA.187@cpmsnbbsa02>...

Lawrence A. Latouf

unread,
Jul 9, 1999, 3:00:00 AM7/9/99
to

Some new information.

I have 2 DLLs, the first one that is loaded, InitInstance is invoked. Then
a BorlandC DLL is loaded. After
that, my second DLL gets loaded, and InitInstance is not invoked.

Both of these DLLs are Regular DLLs that use MFC; therefore, InitInstance
should be invoked upon load.

Help please

Larry

Scott Tunstall <tuns...@email.msn.com> wrote in message
news:OZcR$eKy#GA.115@cpmsnbbsa02...

0 new messages