User32CreateIconFromResourceEx Method

Creates an icon or cursor from resource bits describing the icon.

Definition

Namespace: DevCase.Win32.NativeMethods
Assembly: DevCase.net48 (in DevCase.net48.dll) Version: 6.0.0.0 (6.0)
XMLNS for XAML: Not mapped to an xmlns.
[DllImportAttribute("User32.dll", SetLastError = true)]
public static IntPtr CreateIconFromResourceEx(
	ref byte refResourceBits,
	uint resourceSize,
	bool isIcon,
	uint version,
	int width,
	int height,
	CreateIconFromResourceFlags flags
)

Parameters

refResourceBits  Byte
The buffer containing the icon or cursor resource bits.

These bits are typically loaded by calls to the LookupIconIdFromDirectoryEx and LoadResource(SafeModuleHandle, IntPtr) functions.

resourceSize  UInt32
The size, in bytes, of the set of bits pointed to by the refResourceBits parameter.
isIcon  Boolean
Indicates whether an icon or a cursor is to be created.

If this parameter is , an icon is to be created. If it is , a cursor is to be created.

version  UInt32
The version number of the icon or cursor format for the resource bits pointed to by the presbits parameter. The value must be greater than or equal to 0x00020000 (&H20000 in VB.NET) and less than or equal to 0x00030000 (&H30000 in VB.NET). This parameter is generally set to 0x00030000 (&H30000 in VB.NET).
width  Int32
The desired width, in pixels, of the icon or cursor.

If this parameter is zero, the function uses the SM_CXICON or SM_CXCURSOR system metric value to set the width.

height  Int32
The desired height, in pixels, of the icon or cursor.

If this parameter is zero, the function uses the SM_CYICON or SM_CYCURSOR system metric value to set the height.

flags  CreateIconFromResourceFlags
Flags that determine how the icon is created.

Return Value

IntPtr
If the function succeeds, the return value is a handle to the icon or cursor.

If the function fails, the return value is Zero.

To get extended error information, call GetLastWin32Error.

Remarks

See Also