Answer the question
In order to leave comments, you need to log in
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 DllMain
is not defined. As a result, the DLL will be built DllMain
from MFC, and not the usual Win32 DllMain
, right?
2. If so, then I also need to ensure that I have DllMain
from 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 DllMain
one 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
I’ll answer myself - apparently, MFC is built in DllMain
, you need to include afxwin.h
changes 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 questionAsk a Question
731 491 924 answers to any question