Windows Mobile 6.5
A version of this page is also available for

This function gets a module file name.

WINAPI DWORD GetModuleFileName(
  HMODULE hModule,
  LPWSTR lpFilename,
  DWORD nSize


[in] Handle to the module whose executable file name is being requested.

If this parameter is NULL, GetModuleFileName returns the path for the file used to create the calling process.


[out] Pointer to a buffer that is filled in with the path and file name of the module.


[in] Specifies the length, in characters, of the lpFilename buffer.

If the length of the path and file name exceeds this limit, the string is truncated.

The length, in characters, of the string copied to the buffer indicates success. Zero indicates failure. To get extended error information, call GetLastError.

In Windows Embedded CE, a DLL is loaded from only one location by the system. All DLLs are stripped of their extension before being compared with the loaded module list. This means that Mydll.dll and Mydll.cpl are the same name and only one can be loaded.

Windows Embedded CEWindows CE 2.0 and later
Windows MobileWindows Mobile Version 5.0 and later