HINSTANCE hHandle=AfxGetResourceHandle(); AfxSetResourceHandle(g_Instance); CString strDllPath = lpszPath; if(strDllPath.Right(1)!= "//") strDllPath += "//"; CString strXmlFile = strDllPath + FILENAME; CConfigDlg dlg(strXmlFile,strDllPath); dlg.DoModal(); AfxSetResourceHandle(hHandle); HINSTANCE g_Instance=NULL; static AFX_EXTENSION_MODULE DLLName = { NULL, NULL }; extern "C" int APIENTRY DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved) { // Remove this if you use lpReserved UNREFERENCED_PARAMETER(lpReserved); if (dwReason == DLL_PROCESS_ATTACH) { // Extension DLL one-time initialization if (!AfxInitExtensionModule(DLLName, hInstance)) return 0; g_Instance = DLLName.hResource; new CDynLinkLibrary(TextFileSource2DLL); } else if (dwReason == DLL_PROCESS_DETACH) { // Terminate the library before destructors are called AfxTermExtensionModule(DLLName); } return 1; // ok }