FindResource

Syntax

HANDLE FindResource(hInstance,lpName,lpType)

This function determines the location of a resource in the specified resource file. The lpName and lpType parameters define the resource name and type, respectively.

Parameter Type/Description  

hInstance HANDLE Identifies the instance of the module whose executable file contains the resource.  
lpName LPSTR Points to a null-terminated character string that represents the name of the resource.  
lpType LPSTR Points to a null-terminated character string that represents the type name of the resource. For predefined resource types, the lpType 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)

Return Value

The return value identifies the named resource. It is NULL if the requested resource cannot be found.

Comments

An application must not call FindResource and the LoadResource function to load cursor, icon, and string resources. Instead, it must load these resources by calling the following functions:

LoadCursor

LoadIcon

LoadString

An application can call FindResource and LoadResource 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

If the high-order word of the lpName or lpType parameter is zero, the low-order word specifies the integer ID of the name or type of the given resource. Otherwise, the parameters are long pointers to null-terminated character strings. If the first character of the string is a pound sign (#), the remaining characters represent a decimal number that specifies the integer ID of the resource's name or type. For example, the string #258 represents the integer ID 258.

To reduce the amount of memory required for the resources used by an application, the application should refer to the resources by integer ID instead of by name.