Dave's Brain

Browse - Programming Tips - How can I get the name of the current DLL?

Date: 2012jul25
OS: Windows
Platform: win32
Language: C/C++

Q.  How can I get the name of the current DLL?

A.  Call GetModuleFileName() in DllMain() like this:

char szDll[MAX_PATH]; BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID) { switch(fdwReason) { case DLL_PROCESS_ATTACH: GetModuleFileName(hInstDLL, szDll, sizeof(szDll)); break; case DLL_PROCESS_DETACH: break; } return TRUE; }

Add a comment

Sign in to add a comment
Copyright © 2008-2017, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.