2007-06-14

Customize a Device Icon in WinXP

This information is quoted from the page at Microsoft.com:

Including Icons in Device Driver Packages

Note: The following information will be included in a future 
version of the Windows DDK.

Once you have created a custom icon for a device, you can include
the icon in the device driver package by referencing it in the INF
file. The DDInstall.HW section is used to set driver-independent
information that is device-specific.

In the sample INF sections that follow, the DDInstall.HW section 
points to a separate AddReg section, which specifies the personalized 
icons.

[DDInstall.NT.HW]
AddReg = IconInformation
[IconInformation]
HKR, , Icons, 0x10000, "<name of icon file>"
HKR, , NoMediaIcons, 0x10000, "<name of no media icon file>"

The AddReg section in this example defines two separate registry values and
corresponding icon files, one for the custom icon to display when media is 
present, and a second, "NoMediaIcons," which specifies an icon to be used to 
indicate the same device when no media is inserted.

The following example shows the registry entries for a Vid_0000&Pid_0000 
device and the dynamic-link library (DLL) files that contain the 
"media inserted" and "no media" versions of the icon.

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\USB\ 
 ** remove line break before using! ** 
  Vid_0000&Pid_0000\059B003112010E93\Device Parameters
Icons [REG_MULTI_SZ]= %SystemRoot%\system32\icon.ico
NoMediaIcons [REG_MULTI_SZ]= %SystemRoot%\system32\noicon.ico

In the INF file, icon files must be listed in the [SourceDisksFiles] 
section within the INF file, and copied to the user's system by either a 
CopyFiles directive or a CopyFiles section.

During driver installation, the INF entries listed in the example 
will be stored in the Device Parameters subkey within 
HKLM\System\CurrentControlSet\Enum.

Drivers or other code should never access or modify this registry key 
directly; instead, use one of the following APIs:

* From user-mode, use SetupDiCreateDevRegKey and SetupDiOpenDevRegKey.
 
( From kernel-mode, use IoOpenDeviceRegistryKey.
 

For information about the INF entries cited here, see the Device 
Installation Reference in the current Windows DDK.