EnumResourceNamesA function (libloaderapi.h)

Enumerates resources of a specified type within a binary module. For Windows Vista and later, this is typically a language-neutral Portable Executable (LN file), and the enumeration will also include resources from the corresponding language-specific resource files (.mui files) that contain localizable language resources. It is also possible for hModule to specify an .mui file, in which case only that file is searched for resources.

Syntax

BOOL EnumResourceNamesA(
  [in, optional] HMODULE          hModule,
  [in]           LPCSTR           lpType,
  [in]           ENUMRESNAMEPROCA lpEnumFunc,
  [in]           LONG_PTR         lParam
);

Parameters

[in, optional] hModule

Type: HMODULE

A handle to a module to be searched. Starting with Windows Vista, if this is an LN file, then appropriate .mui files (if any exist) are included in the search.

If this parameter is NULL, that is equivalent to passing in a handle to the module used to create the current process.

[in] lpType

Type: LPCTSTR

The type of the resource for which the name is being enumerated. Alternately, rather than a pointer, this parameter can be MAKEINTRESOURCE(ID), where ID is an integer value representing a predefined resource type. For a list of predefined resource types, see Resource Types. For more information, see the Remarks section below.

[in] lpEnumFunc

Type: ENUMRESNAMEPROC

A pointer to the callback function to be called for each enumerated resource name or ID. For more information, see ENUMRESNAMEPROC.

[in] lParam

Type: LONG_PTR

An application-defined value passed to the callback function. This parameter can be used in error checking.

Return value

Type: BOOL

The return value is TRUE if the function succeeds or FALSE if the function does not find a resource of the type specified, or if the function fails for another reason. To get extended error information, call GetLastError.

Remarks

If IS_INTRESOURCE(lpszType) is TRUE, then lpszType specifies the integer identifier of the given resource type. Otherwise, it is a pointer to a null-terminated string. If the first character of the string is a pound sign (#), then the remaining characters represent a decimal number that specifies the integer identifier of the resource type. For example, the string "#258" represents the identifier 258.

For each resource found, EnumResourceNames calls an application-defined callback function lpEnumFunc, passing the name or the ID of each resource it finds, as well as the various other parameters that were passed to EnumResourceNames.

Alternately, applications can call EnumResourceNamesEx, which provides more precise control of what resources are enumerated.

If a resource has an ID, the ID is passed to the callback function; otherwise the resource name is passed to the callback function. For more information, see ENUMRESNAMEPROC.

The EnumResourceNames function continues to enumerate resources until the callback function returns FALSE or all resources have been enumerated.

Starting with Windows Vista, if hModule specifies an LN file, then the resources enumerated can reside either in the LN file or in a .mui file associated with it. If no .mui files are found, only resources from the LN file are returned. The order in which .mui files are searched is the usual Resource Loader search order; see User Interface Language Management for details. Once one appropriate .mui file is found, the .mui file search stops. Because all .mui files that correspond to a single LN file have the same resource types, only the resources in the found .mui file need to be enumerated.

The enumeration never includes duplicates: if resources with the same name are contained in both the LN file and in an .mui file, the resource will only be enumerated once.

Examples

For an example, see Creating a Resource List.

Requirements

Requirement Value
Minimum supported client Windows 10 Build 20348
Minimum supported server Windows 10 Build 20348
Header libloaderapi.h
Library Kernel32.lib
DLL Kernel32.dll

See also

Conceptual

Reference