How To Get Current Module (dll) Handle

Posted on 2006-04-29
Last Modified: 2008-01-09
I need to get the name of current module (dll). I dont have the HMODULE or the name of the module.

Thanx n Advance
Question by:adnan562
    LVL 19

    Expert Comment

    by:Daniel Van Der Werken

    Author Comment

    Thanx Dan7el

    But using GetModuleHandle() u need to know the name of module, which i mentioned i dont have.
    LVL 2

    Expert Comment

    U can get the HMODULE with
    BOOL WINAPI GetModuleHandleEx(  DWORD dwFlags,  LPCTSTR lpModuleName,  HMODULE* phModule);

    this function retrieve the module from a function pointer contained into the dll:

    void    *functionPtr = ...;
    HMODULE  handle = NULL;
    char     path[MAX_PATH] = "";
    GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, functionPtr, &handle );
    GetModuleFileNameA(handle , path, __countof(path));


    Author Comment


    GetModuleHandleEx is for XP.
    Any solution for windows 2000
    LVL 2

    Accepted Solution


    Author Comment

    Hi MechanTOurS

    Thnx alot MechanTOurS

    Although it dint work for me, caz I am hooking into another process memory but it was of great help thats why I am accepting your answer.


    Author Comment

    Hi all,

    I found a solution many thanx to cmk.

    See this forum at CodeProject


    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    sumNumber challenge 16 81
    Windows 10 SmartScreen vs ClickOnce app 5 92
    copyEndy  challenge 15 41
    sumDigits  challenge 7 41
    Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
    In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
    Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now