Retrieving a DLL Name from a DLL

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);

+5
source share
2 answers

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;
  }
}
+7
source

DllMain, , , GetModuleFilename. GetModuleFilename ( ) DllMain, Windows , .

+4

All Articles