I want to create a dll that unload it self in case of some condifiton, meaning
BOOL APIENTRY DllMain( HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
{
if (ul_reason_for_call==DLL_PROCESS_ATTACH)
if (!CheckSomething()) //check if a file doesnt exists for example
FreeLibrary(hModule);
}
I tried it, but i couldnt get it to work. if there is any walk around alternative solution. please tell me, I dont want the process which attached the dll to unload it, I want it to unload it self
You can't unload the DLL, it hasn't been loaded yet. That's what the BOOL
return is for. If you don't want to load the DLL, then return FALSE
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With