Muokkaa

Jaa


Providing Icons for a Device

This topic describes how you can provide custom icons for a device by referencing them in a driver's INF file. You can provide icons that appear in Device Manager, Windows Explorer, or both, as appropriate.

Adding icons for Device Manager

You can either embed a custom icon in a DLL or provide a standalone .ico file. If your driver is already a DLL file, the first is the easiest option because it does not require copying any additional files.

To embed the icon in a DLL, use an entry like this:

[<DDInstall>]
AddProperty = DeviceIconProperty

[DeviceIconProperty]
DeviceIcon,,,,"%13%\UmdfDriver.dll,-100"

The above example uses DIRID 13 to copy the file to the Driver Store, which avoids needing to copy it anywhere else. The entry follows the format <Resource.dll>,-<IconResourceID>, so the 100 signifies the resource ID of the icon in the resource table of the DLL. For more on DIRID 13, see Using a Universal INF File.

To reference a standalone .ico file, use an entry like this:

[<DDInstall>]
AddProperty = DeviceIconProperty

[DeviceIconProperty]
DeviceIcon,,,,"%13%\vendor.ico"

Adding icons for storage volumes in Explorer

The shell uses Icons and NoMediaIcons registry values to represent the device in AutoPlay, My Computer, and file Open dialog boxes.

To add these, include an INF AddReg directive under an INF DDInstall.HW section for the device. In the AddReg section, specify Icons and NoMediaIcons value entries, as shown in the following example:

[DDInstall.NT.HW]
AddReg = IconInformation

[IconInformation]
HKR, , Icons, 0x10000, "media-inserted-icon-file"
HKR, , NoMediaIcons, 0x10000, "no-media-inserted-icon-file"

Then include an INF SourceDisksFiles section that lists the icon files and a corresponding INF CopyFiles directive that copies them to the system.

The Icons and NoMediaIcons value entries are stored under the device's hardware key which would contain entries like the following:

  • Icons [REG_MULTI_SZ] = %SystemRoot%\system32\icon.ico

  • NoMediaIcons [REG_MULTI_SZ] = %SystemRoot%\system32\noicon.ico

Resources

When you create icons, follow the guidelines that are provided in Icons. These guidelines describe how to create icons that have the appearance and behavior of Windows graphical elements.