CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Dec 2001
    Posts
    76

    Window Enumeration

    How can i get the .exe file name of a program , given a handle to one of its windows?

    Thanks for any help

  2. #2
    Join Date
    Sep 2002
    Location
    Belarus - Tirol, Austria
    Posts
    647
    Try to use GetWindowModuleFileName function.
    It retrieves the full path and file name of the module associated with the specified window handle.

    UINT GetWindowModuleFileName(
    HWND hwnd, // handle to window
    LPTSTR lpszFileName, // file name buffer
    UINT cchFileNameMax // max size of file name buffer
    );
    "UNIX is simple; it just takes a genius to understand its simplicity!"

  3. #3
    Join Date
    Dec 2001
    Posts
    76
    thanks for your reply. After looking at the documentation it says it still in prelimary documentation which probubly means its gonna only work on win2000 and XP. Right now im using CToolHelp and it assocaited functions like Module32First. But if worked on win98 systems i would use your recommendation instead. To bad I dont have a win98 system around here

    Thanks for your reply.

  4. #4
    Join Date
    May 2000
    Location
    Phoenix, AZ [USA]
    Posts
    1,347
    It should be supported on all the recent windows we've all come
    to know and love:
    Requirements
    Windows NT/2000/XP: Included in Windows NT 3.1 and later.
    Windows 95/98/Me: Included in Windows 95 and later.
    Unicode: Implemented as Unicode and ANSI versions on Windows
    NT/2000/XP. Also supported by Microsoft Layer for Unicode.
    Header: Declared in Winbase.h; include Windows.h.
    Library: Use Kernel32.lib.

    http://msdn.microsoft.com/library/de...lefilename.asp

  5. #5
    Join Date
    Dec 2001
    Posts
    76
    Hey thanks, but did you notice that the signature is different from the one that dimm_coder provided? The function he provided used the HWND of a window and the one you posted a link to uses a HMODULE. Whats up with that?

    Brandon

  6. #6
    Join Date
    May 2000
    Location
    Phoenix, AZ [USA]
    Posts
    1,347
    Yikes. It's because I posted the link to a different function.

    Minimum operating systems Included in Windows 95, Windows NT
    4.0 SP3
    http://msdn.microsoft.com/library/de...lefilename.asp

    I apologize for doing that.

    --Paul

  7. #7
    Join Date
    Dec 2001
    Posts
    76
    Hey no prob slick. I need to find a win98 machine to see if this is going to work on both win98 and NT(XP).

    Thanks for your comments and hints.
    Brandon

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured