HANDLE GetModuleHandle(lpszModule) | |||||
LPCTSTR lpszModule; | /* module name to return handle for | */ |
The GetModuleHandle function returns a module handle for the specified image file.
lpszModule
Points to a null-terminated string that names the file to return the module handle for. If this parameter is NULL, GetModuleHandle returns a handle for the file used to create the current process.
If the function is successful, the return value is a module handle for the specified image file.
If the specified file has not been loaded in the context of the current process or an error occurs, the return value is NULL. Use the GetLastError function to obtain extended error information.
The GetModuleHandle function may be used as either a wide-character function (where text arguments must use Unicode) or an ANSI function (where text arguments must use characters from the Windows 3.x character set installed).
This function must be used carefully in a multi-threaded application. There is no guarantee that the module handle will remain valid between the time this function returns the handle and the time the handle is used by another function. For example, another thread in the same process could preempt the currently running thread and free the module, or another module could be loaded and given the same module handle, causing the handle returned by GetModuleHandle to refer to a different module than the one intended.
FreeModule, GetModuleFileName, GetProcAddress, LoadModule