If I have a dll called "foo.dll" and the end user renames it to "bar.dll" and LoadLibrary, how can I get the name "bar.dll" from my DLL?
This is GetModuleFilename (hModule, buffer);
yes you need to save hModule in DllMain
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) { switch (fdwReason) { case DLL_PROCESS_ATTACH: hModule = hinstDLL; break; } }
DllMain, , , GetModuleFilename. GetModuleFilename ( ) DllMain, Windows , .