FindResource

2.x

  HRSRC FindResource(hinst, lpszName, lpszType)    
  HINSTANCE hinst; /* handle of module containing resource */
  LPCSTR lpszName; /* address of resource name */
  LPCSTR lpszType; /* address of resource type */

The FindResource function determines the location of a resource in the specified resource file.

Parameters

hinst

Identifies the instance of the module whose executable file contains the resource.

lpszName

Specifies the name of the resource. For details, see the following Comments section.

lpszType

Specifies the resource type. For details, see the following Comments section. For predefined resource types, this parameter should be one of the following values:

Value Meaning

RT_ACCELERATOR Accelerator table
RT_BITMAP Bitmap resource
RT_CURSOR Cursor resource
RT_DIALOG Dialog box
RT_FONT Font resource
RT_FONTDIR Font directory resource
RT_ICON Icon resource
RT_MENU Menu resource
RT_RCDATA User-defined resource (raw data)
RT_STRING String resource

Return Value

The return value is the handle of the named resource if the function is successful. Otherwise, it is NULL.

Comments

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 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 identifier instead of by name.

An application must not call the FindResource and LoadResource functions to load cursor, icon, and string resources. Instead, it must load these resources by calling the LoadCursor, LoadIcon, and LoadString functions, respectively.

Although the application can call the FindResource and LoadResource functions to load other predefined resource types, it should load the corresponding resources by calling the LoadAccelerators, LoadBitmap, and LoadMenu functions.

See Also

LoadAccelerators, LoadBitmap, LoadCursor, LoadIcon, LoadMenu, LoadResource, LoadString