I have a dynamic call to a DLL from another DLL that is statically linked to the calling application
In debug mode the call works fine
When I run the code in release mode I get a crash when the QueryLoginDynamicCall function returns
snippet from Test.dll
snippet from calling DLL
If I remove the line where the function is actually called, the code doesn't crash.
eg use nRetVal = 0; //pUserCheckLogin(pszUserName,pbResult);
Can anyone tell me what Im doing wrong?
Go not to cats for advice for they will just walk over the keyboard
In debug mode the call works fine
When I run the code in release mode I get a crash when the QueryLoginDynamicCall function returns
snippet from Test.dll
Code:
#include "Permission.h"
#define DLLExport _declspec( dllexport )
extern "C"
{
DLLExport int GetUserLoginAuto(char * pszUserName, BOOL* pbPermission);
}
int GetUserLoginAuto(char * pszUserName, BOOL* pbPermission)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
CPermission test;
test.m_strUserName = pszUserName;
int nRet = test.DoModal();
*pbPermission = test.m_bPermissionToLogin;
if (nRet !=IDOK)
test.m_nErrorCode = nRet;
return test.m_nErrorCode;
}
snippet from calling DLL
If I remove the line where the function is actually called, the code doesn't crash.
eg use nRetVal = 0; //pUserCheckLogin(pszUserName,pbResult);
Code:
int LoginForm::QueryLoginDynamicCall(char *pszUserName, BOOL *pbResult)
{
int nRetVal = -1;
*pbResult = FALSE;
HMODULE hTest = LoadLibrary("test.dll");
if (hTest)
{
LPFNDLLFUNC1 pUserCheckLogin = (LPFNDLLFUNC1)GetProcAddress(hTest,"GetUserLoginAuto");
if (pUserCheckLogin)
nRetVal = pUserCheckLogin(pszUserName,pbResult);
else
nRetVal = -1;
FreeLibrary(hTest);
}
return nRetVal;
}
Can anyone tell me what Im doing wrong?
Go not to cats for advice for they will just walk over the keyboard