LookupIconIdFromDirectory

  int LookupIconIdFromDirectory(presbits, fIcon)    
  PBYTE presbits;    
  BOOL fIcon;    

The LookupIconIdFromDirectory function searches through an icon or cursor directory for a specific icon or cursor that best fits the current display device.

Parameters

presbits

Points to the icon or cursor directory resource for any particular icon or cursor.

fIcon

Specifies whether an icon or a cursor is being looked for. A value of TRUE specifies an icon, FALSE specifies a cursor.

Return Value

If the function is successful, the return value is an integer resource id for the icon or cursor that best fits the current display device.

The function doesn't validate the directory bits as they come in. Thus, the application will GP fault, or return some spurious value, if invalid directory bits cause it to be unsuccessful.

Comments

Icons and cursors are stored in device dependent and independent formats in resource files. When the function LoadIcon is called, the system searches through an icon directory for a specific icon, looking for the icon that best fits the current display device. A similar process occurs when the function LoadCursor is called. The LookupIconIdFromDirectory function performs this search operation.

The presbits parameter points to the icon or cursor directory. The icon directory is loaded from a resource file with resource type RT_GROUP_ICON (or RT_GROUP_CURSOR for cursors), and an integer resource name for the particular icon to be loaded. The LookupIconIdFromDirectory function returns an integer id that is the resource name of the icon that best fits the current display device. The resource bits for this icon can be loaded with resource type RT_ICON (or RT_CURSOR for cursors), and with a resource name of this id. Remember to use the MAKEINTRESOURCE() macro around resource names that are integers. See the Comments section of CreateIconFromResource for some sample code that illustrates all of this.

An application can load resources from .DLLs and .EXEs. To load a resource from a .DLL, call LoadModule to get an hModule handle that can then be used with FindResource, LoadResource, and other resource-loading API functions. Similarly, to load a resource from an .EXE, call LoadLibrary to get an hModule handle that can then be used with resource-loading API functions.

See Also

CreateIconFromResource, CreateIconIndirect, GetIconInfo