Click to See Complete Forum and Search --> : From a DLL module, how to get the file path of itself at runtime?


cyberninja
June 13th, 2003, 10:37 PM
From a DLL module, how to get the file path of itself at runtime? I know GetModuelFileName(), which returns the path to the file path of the EXE (caller process) instead of the DLL module itself.

(Assume EXE who calles Loadlibrary() is not in the same folder as the DLL)

Thanks,

Ming

rxbagain
June 13th, 2003, 10:58 PM
Save the HMODULE of HINSTANCE in your Dll's DllMain and use it in GetModuleFileName's first parameter.

Hope it will help you

Lighthill
June 14th, 2003, 04:42 AM
You have to call GetModuleHandle to get a handle you can use for GetModuleFileName.

Andreas Masur
June 14th, 2003, 04:56 AM
Depending on the kind of your dll, another way would be using 'AfxGetInstanceHandle()'....