In the Application Development of MFC, some functions are often encapsulated and called in the DLL dynamic library. The following points should be noted during the call process:
1. Set the current resource handle
When searching resource files in DLL, set the handle of the current resource file to the hinstance of the DLL module if necessary.
Afxgetresourcehandle () view the current resource handle
Afxsetresourcehandle () sets the current resource handle
Getmodulehandle ("DLL file name ");
Example:
Hinstance H1 = afxgetresourcehandle ();
Hmodule hmod = getmodulehandlea ("ActiveX. ocx ");
If (hmod = NULL) hmod = getmodulehandlea ("ActiveX. dll ");
Afxsetresourcehandle (hmod );
2. COM Initialization and container settings are required when ActiveX is called in DLL.
Oleinitialize (null); COM interface Initialization
Afxenablecontrolcontainer () allows applications to be used as control containers.
The problems currently encountered are basically the above two points. New discoveries will be added in the future.