thanks couling. two things: one method that works is as zaccheus said using another external
function in the dll to delete the object. secondly, and this actually fixed my original
problem with LoadLibrary/FreeLibrary. I was looking at the documentation for
FreeLibrary and it says when it is called it will call DllMain. i didn't previously have
that so i added the following -
Code:
BOOL WINAPI DllEntryPoint(HINSTANCE, DWORD, LPVOID)
{
	return TRUE;
}