Click to See Complete Forum and Search --> : Window Enumeration


BrandonParker
September 24th, 2002, 12:00 AM
How can i get the .exe file name of a program , given a handle to one of its windows?

Thanks for any help

dimm_coder
September 24th, 2002, 12:50 AM
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
);

BrandonParker
September 24th, 2002, 02:48 AM
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:mad:

Thanks for your reply.

PaulWendt
September 24th, 2002, 06:17 AM
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/default.asp?url=/library/en-us/dllproc/base/getmodulefilename.asp

BrandonParker
September 24th, 2002, 03:42 PM
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

PaulWendt
September 24th, 2002, 04:10 PM
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/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/windows/windowreference/windowfunctions/getwindowmodulefilename.asp

I apologize for doing that.

--Paul

BrandonParker
September 24th, 2002, 06:04 PM
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