Reputation: 3130
I have an MFC .exe application, and I created another project for a DLL with MFC dynamically linked to it.
Now, when I import that DLL through LoadLibrary, it crashes my application, because when the importing is done, the DLL calls AfxWinInit()
.
Should the DLL call AfxWinInit()
? How do I avoid it? Or is something else wrong?
Upvotes: 0
Views: 2267
Reputation: 6566
In your MFC application WinMain()
calls AfxWinMain().
The AfxWinInit()
is called at the beginning of AfxWinMain().
So the initialization is done by framework for you. There is no need to initialize it again.
MFC DLLs provide their own entry point, so you're not supposed to write one yourself. If you plan to write a DLL with MFC support, I'd suggest you start with a fresh MFC DLL created by the app wizard and then move your code there.
For MFC applications that load extension DLLs, use AfxLoadLibrary
instead of LoadLibrary
.
Upvotes: 3