Correct module handle

Hi.

How I can obtain a module handle to current dynamic link library (within itself) loaded by an another process

I need a module handle within a library loaded by an application, but GetModuleHandle return an handle to application module instead to library module.

For example. I put this code within a library function.

LPWCH lpModuleName = new WCHAR [MAX_PATH];
GetModuleFileName (GetModuleHandle (0), lpModuleName, MAX_PATH);

lpModuleName will point to an array of WCHAR filled with the application path instead the library (DLL) path loaded by the application.

I hope I was clear.

I'm terribly sorry for my english! .
Thanks in advance.
Ciao guaglio!




Answer this question

Correct module handle

  • Enrico Sicignano

    You get the module handle were your DLL is loaded in the DllMain!

  • Correct module handle