GetWindowModuleFileNameA function (winuser.h)

Retrieves the full path and file name of the module associated with the specified window handle.


UINT GetWindowModuleFileNameA(
  [in]  HWND  hwnd,
  [out] LPSTR pszFileName,
  [in]  UINT  cchFileNameMax


[in] hwnd

Type: HWND

A handle to the window whose module file name is to be retrieved.

[out] pszFileName


The path and file name.

[in] cchFileNameMax

Type: UINT

The maximum number of characters that can be copied into the lpszFileName buffer.

Return value

Type: UINT

The return value is the total number of characters copied into the buffer.



The winuser.h header defines GetWindowModuleFileName as an alias which automatically selects the ANSI or Unicode version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions for Function Prototypes.


Requirement Value
Minimum supported client Windows 2000 Professional [desktop apps only]
Minimum supported server Windows 2000 Server [desktop apps only]
Target Platform Windows
Header winuser.h (include Windows.h)
Library User32.lib
DLL User32.dll

See also

Windows Overview