编写了一个扩展的dll,供外部程序调用的。可是出现了问题不知道该如何解决。
问题现象是调用dll中的一个窗体完成登录。在dll的导出函数中 中使用 dlg->DoModule() dll程序进入到DllMain中
然后循环两次后就出现 assetion failed 错误
说文件是afxwin1.inl
位置在22行不知道怎么回事啊,各位老大救命。
DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
{
// Remove this if you use lpReserved
UNREFERENCED_PARAMETER(lpReserved); if (dwReason == DLL_PROCESS_ATTACH)
{
TRACE0("LOGIN.DLL Initializing!\n");
// Extension DLL one-time initialization
if (!AfxInitExtensionModule(LoginDLL, hInstance))
return 0; // Insert this DLL into the resource chain
// NOTE: If this Extension DLL is being implicitly linked to by
// an MFC Regular DLL (such as an ActiveX Control)
// instead of an MFC application, then you will want to
// remove this line from DllMain and put it in a separate
// function exported from this Extension DLL. The Regular DLL
// that uses this Extension DLL should then explicitly call that
// function to initialize this Extension DLL. Otherwise,
// the CDynLinkLibrary object will not be attached to the
// Regular DLL's resource chain, and serious problems will
// result. new CDynLinkLibrary(LoginDLL);
}
else if (dwReason == DLL_PROCESS_DETACH)
{
TRACE0("LOGIN.DLL Terminating!\n");
// Terminate the library before destructors are called
AfxTermExtensionModule(LoginDLL);
}
return 1; // ok
}
extern "C" _declspec(dllexport) BOOL UserLogin(char *strDepartment,_ConnectionPtr dllconn)
{
strdllDepartment=strDepartment;
CDlgLogin *dlg=new CDlgLogin();
dlg->m_conn=dllconn;
if(dlg->DoModal()==IDOK) //执行到这里就跳入了DLLMain开始循环了,dlg就是一个一般的窗体
{
delete dlg;
return TRUE;
}
else
{
delete dlg;
return FALSE;
}}调用代码typedef BOOL (*FuncUserLogin)(char *,_ConnectionPtr);
HINSTANCE hInstance=LoadLibrary("Login.dll");
FuncUserLogin pUserLogin=(FuncUserLogin)GetProcAddress(hInstance,"UserLogin");
if(pUserLogin(strCurrentUser.strCurrentUserDepartment.GetBuffer(10),GlobalConn)==false)
{
return FALSE;
}
strCurrentUser.strCurrentUserDepartment.ReleaseBuffer();
FreeLibrary(hInstance);
问题现象是调用dll中的一个窗体完成登录。在dll的导出函数中 中使用 dlg->DoModule() dll程序进入到DllMain中
然后循环两次后就出现 assetion failed 错误
说文件是afxwin1.inl
位置在22行不知道怎么回事啊,各位老大救命。
DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
{
// Remove this if you use lpReserved
UNREFERENCED_PARAMETER(lpReserved); if (dwReason == DLL_PROCESS_ATTACH)
{
TRACE0("LOGIN.DLL Initializing!\n");
// Extension DLL one-time initialization
if (!AfxInitExtensionModule(LoginDLL, hInstance))
return 0; // Insert this DLL into the resource chain
// NOTE: If this Extension DLL is being implicitly linked to by
// an MFC Regular DLL (such as an ActiveX Control)
// instead of an MFC application, then you will want to
// remove this line from DllMain and put it in a separate
// function exported from this Extension DLL. The Regular DLL
// that uses this Extension DLL should then explicitly call that
// function to initialize this Extension DLL. Otherwise,
// the CDynLinkLibrary object will not be attached to the
// Regular DLL's resource chain, and serious problems will
// result. new CDynLinkLibrary(LoginDLL);
}
else if (dwReason == DLL_PROCESS_DETACH)
{
TRACE0("LOGIN.DLL Terminating!\n");
// Terminate the library before destructors are called
AfxTermExtensionModule(LoginDLL);
}
return 1; // ok
}
extern "C" _declspec(dllexport) BOOL UserLogin(char *strDepartment,_ConnectionPtr dllconn)
{
strdllDepartment=strDepartment;
CDlgLogin *dlg=new CDlgLogin();
dlg->m_conn=dllconn;
if(dlg->DoModal()==IDOK) //执行到这里就跳入了DLLMain开始循环了,dlg就是一个一般的窗体
{
delete dlg;
return TRUE;
}
else
{
delete dlg;
return FALSE;
}}调用代码typedef BOOL (*FuncUserLogin)(char *,_ConnectionPtr);
HINSTANCE hInstance=LoadLibrary("Login.dll");
FuncUserLogin pUserLogin=(FuncUserLogin)GetProcAddress(hInstance,"UserLogin");
if(pUserLogin(strCurrentUser.strCurrentUserDepartment.GetBuffer(10),GlobalConn)==false)
{
return FALSE;
}
strCurrentUser.strCurrentUserDepartment.ReleaseBuffer();
FreeLibrary(hInstance);
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货