Platform SDK: DLLs, Processes, and Threads |
The GetModuleFileName function retrieves the full path and file name for the file containing the specified module.
Windows 95/98: The GetModuleFilename function retrieves long file names when an application's version number is greater than or equal to 4.00 and the long file name is available. Otherwise, it returns only 8.3 format file names.
DWORD GetModuleFileName( HMODULE hModule, // handle to module LPTSTR lpFilename, // file name of module DWORD nSize // size of buffer );
If the function succeeds, the return value is the length, in TCHARs, of the string copied to the buffer.
If the function fails, the return value is zero. To get extended error information, call GetLastError.
If a DLL is loaded in two processes, its file name in one process may differ in case from its file name in the other process.
Windows NT/2000: Requires Windows NT 3.1 or later.
Windows 95/98: Requires Windows 95 or later.
Header: Declared in Winbase.h; include Windows.h.
Library: Use Kernel32.lib.
Unicode: Implemented as Unicode and ANSI versions on Windows NT/2000.
Dynamic-Link Libraries Overview, Dynamic-Link Library Functions, GetModuleHandle, LoadLibrary