below code works correctly in Debug mode, but in Release, the GetProcAddress seems return NULL, but I can't debug the release mode code, Why it doesn't work with Release mode?
SetString("Library Init Error");
if (_DllHandle == NULL)
{
_DllHandle = LoadLibrary("DogCheck.dll");
}
if (_CheckFunc == NULL && _DllHandle != NULL)
{
_CheckFunc = (CheckTheLicense)GetProcAddress(_DllHandle, "CheckTheLicense");
}
if (_CloseCheckFunc == NULL && _DllHandle != NULL)
{
_CloseCheckFunc = (CloseCheckTheLicense)GetProcAddress(_DllHandle, "CloseCheckTheLicense");
}
if (_CheckFunc != NULL && _CloseCheckFunc != NULL)
{
PCHAR result = _CheckFunc();
SetString(result);
_CloseCheckFunc(result);
}
else
{
if (_DllHandle == NULL)
{
SetString("DLL NULL");
}
else
{
if (_CheckFunc == NULL)
{
SetString("_CheckFunc NULL");
}
}
}
I also find, below code works in both Debug and Release mode:
HINSTANCE dllHandle = LoadLibrary("DogCheck.dll");
if (dllHandle != NULL)
{
CheckTheLicense func = (CheckTheLicense)GetProcAddress(dllHandle, "CheckTheLicense");
if (func != NULL)
{
PCHAR result = func();
SetString(result);
CloseCheckTheLicense funcClose = (CloseCheckTheLicense)GetProcAddress(dllHandle, "CloseCheckTheLicense");
if (funcClose != NULL)
{
funcClose(result);
}
}
FreeLibrary(dllHandle);
}