How can i get the .exe file name of a program , given a handle to one of its windows?
Thanks for any help
Printable View
How can i get the .exe file name of a program , given a handle to one of its windows?
Thanks for any help
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
);
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.
It should be supported on all the recent windows we've all come
to know and love:
Quote:
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
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
Yikes. It's because I posted the link to a different function.
http://msdn.microsoft.com/library/de...lefilename.aspQuote:
Minimum operating systems Included in Windows 95, Windows NT
4.0 SP3
I apologize for doing that.
--Paul
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