HRSRC FindResource(hModule, lpszName, lpszType) | |||||
HANDLE hModule; | /* identifies module containing resource | */ | |||
LPCTSTR lpszName; | /* specifies the resource name | */ | |||
LPCTSTR lpszType; | /* specifies the resource type | */ |
The FindResource function determines the location of a resource in the specified resource file.
hModule
Identifies the module whose executable file contains the resource.
lpszName
Specifies the name of the resource. See the Comments section for more details.
lpszType
Specifies the resource type. See the Comments section for more details. For predefined resource types, this parameter should be one of the following values:
Value | Meaning |
RT_ACCELERATOR | Accelerator table |
RT_BITMAP | Bitmap resource |
RT_DIALOG | Dialog box |
RT_FONT | Font resource |
RT_FONTDIR | Font directory resource |
RT_MENU | Menu resource |
RT_RCDATA | User-defined resource (raw data) |
RT_STRING | String-table entry |
RT_MESSAGETABLE | Message-table entry |
RT_CURSOR | Hardware-dependent cursor resource |
RT_GROUP_CURSOR | Hardware-independent cursor resource |
RT_ICON | Hardware-dependent icon resource |
RT_GROUP_ICON | Hardware-independent icon resource |
RT_VERSION | Version resource |
If the function is successful, the return value is a handle to the specified resource. Otherwise, the return value is NULL. Use the GetLastError function to obtain extended error information.
If the high-order word of the lpszName or lpszType parameter is zero, the low-order word specifies the integer identifier of the name or type of the given resource. Otherwise, the parameters are long pointers to null-terminated strings. If the first character of the string is a pound sign (#), the remaining characters represent a decimal number that specifies the integer identifier of the resource's name or type. For example, the string #258 represents the integer identifier 258.
To reduce the amount of memory required for the resources used by an application, the application should refer to the resources by integer identifier instead of by name.
An application should not use the FindResource, FindResourceEx, and LoadResource functions to load cursor, icon, string or message-string resources, unless it needs access to the binary resource data. Instead, it should load these resources by calling the following functions:
LoadCursor
LoadIcon
LoadString
FormatMessage
An application can use the FindResource, FindResourceEx, and LoadResource functions to load other predefined resource types. However, it is recommended that the application load the corresponding resources by calling the following functions:
LoadAccelerators
LoadBitmap
LoadMenu
The FindResource 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).
FindResourceEx, LoadAccelerators, LoadBitmap, LoadCursor, LoadIcon, LoadMenu, LoadResource, LoadString, FormatMessage, LockResource, SizeofResource