M
M
MikhailEdoshin2011-03-10 14:16:48
Windows
MikhailEdoshin, 2011-03-10 14:16:48

MFC in "regular" Win32 DLL and DLLMain?

Who understands MFC, please tell me if I understand the following two points correctly:
1. In a regular Win32 DLL, the developer includes a static link with MFC and uses some MFC classes (for example, include "afxdlgs.h"and CFileDialog). The function DllMainis not defined. As a result, the DLL will be built DllMainfrom MFC, and not the usual Win32 DllMain, right?
2. If so, then I also need to ensure that I have DllMainfrom MFC, but I already have DllMain. (Now I have a pure Win32 DLL, and the main application uses MFC, I'm trying to figure out one incomprehensible bug with modal dialogs, and suspicion falls precisely on MFC.) Tell me how can I correctly rewrite the existing DllMainone to connect MFC. Here is the outline:
include? /* don't know which header to include */
class MyDll: public CWinApp
{
public:
/* do you need a constructor/destructor? */
virtual BOOL InitInstance();
virtual BOOL ExitInstance();
} theDll;
BOOL
MyDLL::InitInstance()
{
CWinApp::InitInstance();
/* code from DllMain, DLL_PROCESS_ATTACH. hInst in theDll.m_hInstance */
return TRUE;
}
BOOL
MyDLL::ExitInstance()
{
/* code from DllMain, DLL_PROCESS_DETACH */
return CWinApp::ExitInstance();
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
MikhailEdoshin, 2011-03-14
@MikhailEdoshin

I’ll answer myself - apparently, MFC is built in DllMain, you need to include afxwin.hchanges like I write, it only ExitInstance()returns int. Just in case, I made the constructor empty, as in the examples, why I need it in C ++, I still don’t understand.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question