Initiating MFC class from another dll
I have made an MFC application (VS2010) - exe.I then changed it to be dll (in project properties).
Some class CmyClass is inheriting CWinApp in my MFC dll.
From the other DLL (standard win32 DLL) I want to create the class and call it as it made by running the MFC as application (EXE).
I have tried to declare the CmyClass with DLLEXPORT, in my win32 DLL I Load the MFC dll dynamically and performing AfxWinInit with the hinstance of the MFC dll. I have tried than to:
- Create (CmyClass * a= new CmyClass()), wanted to 开发者_如何学JAVAcall InitApplication(), InitInstance() and Run()
- Call AfxGetApp() -> retrieving NULL pointer.
All without success. What Am I doing wrong?
10x, Guy
EDIT:
I need the other way around though... I have created MFC App since it's wizard is wider and richer then the MFC Dll one. I want to consume this Dll the same manner I will consume the App (Exe). I found that from the consuming Dll it is sufficient just to LoadLibrary(MFCDll) to start the MFC Initialization (AfxWinInit is called and CMyClass->InitInstance is being called as well, but fails afterwards with exceptions.
精彩评论