If I use the FreeLibrary function [FreeLibrary("dll_name.dll");] to free up the dll I'm using, the program executes the notice 3x (2x saying it successfully freed it up, and the last saying it didn't...so code below for details) the game crashes.
I'm using Microsoft Visual C++ 6.0 w/ the Win32 API on a WinXP Home Edition system.
If you want the source for the way I'm doing it, here it is:
Code:
#ifndef __GLOBALS_H
#define __GLOBALS_H
#include "log.h" // Logging works fine
HINSTANCE tok = LoadLibrary("tokenizer.dll"); // Loads the tokenizer.dll
// File-handling globals
char szCode[1024]; // Arrary to hold the source code
// Error handling
char *szError;
// Check to see if the library is free, if so, or if not, notify the user...even if something is wrong
bool CheckFree()
{
if(tok)
{
bool Lib2Free = FreeLibrary(tok);
if(Lib2Free == false)
{
szError = "Unable to free tokenizer.dll!";
MessageBox(NULL, szError, NULL, NULL);
szDataToLog(szError);
}
else if(Lib2Free == true)
{
szError = "Successfully freed tokenizer.dll data!";
MessageBox(NULL, szError, NULL, NULL);
szDataToLog(szError);
}
else
{
szError = "Undefined exception, unable to determin tokenizer state!";
MessageBox(NULL, szError, NULL, NULL);
szDataToLog(szError);
}
return true;
}
else
{
szError = "Unable to unload tokenizer.dll!";
MessageBox(NULL, szError, NULL, NULL);
szDataToLog(szError);
}
return false;
}
#endif
[I took out the stuff that isn't of any importance to my question.]