problem with delay loading DLLs 
Author Message
 problem with delay loading DLLs

In VC++ 6.0, when I specify the /DELAYLOAD linker option to delay load a
specific DLL in my application, I get a bunch of MFC asserts at runtime,
then a crash.  I tracked this down to the AfxGetInstanceHandle () routine.
It is supposed to return the instance of the EXE, as long as it's called
from within the EXE.  However, after LoadLibrary gets called, it changes to
the instance of the last DLL loaded.  Example code in InitInstance of my
app:
HINSTANCE hInst;
hInst = AfxGetInstanceHandle ();
HMODULE hDll = ::LoadLibrary ("MyDll.dll");
hInst = AfxGetInstanceHandle ();

The first AfxGetInstanceHandle call returns the EXE instance.  The second
returns the "MyDll.dll" instance.  This leads to the asserts and the crash.
If the /DELAYLOAD option is not specified, both calls return the EXE
instance and everything runs fine.   Anyone know anything about this?
-Scott Haynie



Sat, 01 Sep 2001 03:00:00 GMT  
 problem with delay loading DLLs

Quote:
>I'm sorry, the explicit LoadLibrary call was just an example.  If I replace
>the LoadLibrary call with a call to a delayload DLL routine, I get the same
>result.

Is the DLL that's delayloaded an MFC based DLL, or not?

Do you have a simple series of steps that someone can follow to
reproduce the problem from a clean project?

Dave
----
My address is altered to discourage junk mail.
Please post responses to the newsgroup thread,
there's no need for follow-up email copies.



Sun, 02 Sep 2001 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. problem with delay loading DLLs

2. problem with delay loading DLLs

3. Delay Load DLL doesn't work for C++ DLL

4. Delay Loading oleacc.dll

5. delay load of DLLs

6. Delaying loading of DLLs

7. Delaying loading of DLLs

8. Long delays loading files

9. Delay Load Imports

10. delay load and warning LNK4199

11. reduce delay of delete... (deleting longer than loading)

12. loading an MFC DLL that was originally an extension dll from a non MFC dLL

 

 
Powered by phpBB® Forum Software