How can I make my custom namespace extension get categorized correctly in My Computer?


A customer was developing a custom namespace extension and they found that when displayed in My Computer, it showed up in the Other category.

Name Type
Hard Disk Drives (3)
OS (C:) Local Disk
DISK_1 (E:) Local Disk
DISK_2 (F:) Local Disk
Devices with Removable Storage (1)
DVD RW Drive (D:) CD Drive
Network Locations (1)
share (\\server) (Z:) Network Drive
Other (1)
NAS Device System Folder

They wanted it to appear in the Network Locations category because it represented a network device.

Explorer categorizes the items based on the SH­DESCRIPTION­ID.dwDescription­Id. We saw this structure some time ago when we tried to detect the Recycle Bin. By default shell namespace extensions are given SHDID_COMPUTER_OTHER as their description ID and the clsid is the class ID of the shell extension itself.

To customize the description ID, go to the shell namespace registration and add the following:

HKEY_CLASSES_ROOT\
    CLSID\
        {clsid}\
            DescriptionID=REG_DWORD:9

The magic number 9 is SHDID_COMPUTER_NET­DRIVE. You can use any of the values supported by the SH­DESCRIPTION­ID structure. For example, if your shell extension wraps a file system directory, you may want to use SHDID_FS_DIRECTORY so that it gets categorized under Folders.

Comments (12)
  1. Brian_EE says:

    I would have personally directed them to SHDID_COMPUTER_DRIVE525

  2. Spookily relevant to an upcoming project of mine. Thanks :)

  3. Henri Hein says:

    Brian,

    You are either brilliant or devious.  Possibly both.

  4. cheong00 says:

    Since I see the value for removable drive there, this reminds me of an unsolved issue:

    social.msdn.microsoft.com/.../windows-api-to-detect-a-removable-diskdisplayed-as-local-disk

    As you can see from the linked question, the flash drive manufacturers are following Microsoft's instruction to NOT indicate their device as "removable media". Is there any guideline from Microsoft for programmers to easily detect whether a drive is flash drive?

  5. Anon says:

    @cheong00

    The questions that should be asked there are: "Why do you need to detect removable media? What difference does it make?"

    the answer to OP's question in that case is: tell the user to select the appropriate device.

  6. viila says:

    @anon "Why do you need to detect removable media? What difference does it make?"

    To make it easier for the user TO select the appropriate device? There would be several use cases where the prime target would be a removable device, such as for external backups, or putting a device's firmware update on a flash card (which you can then take TO the device), etc.

    Not to mention that in almost every user's mental model an SD card, a USB stick, etc. ARE removable media.

  7. bv1 says:

    Removable makes a difference for some GPO's and corp. policies.  (Check to make sure all usb thumbdrives are secured with encryption. Certain machines have a policy that does not allow removable media use, etc.)

  8. Anon says:

    @bv1

    In a security context, all devices that aren't soldered to the motherboard should be considered "removable," and even then...

  9. Andreas Rejbrand says:

    Using U+23CD: SQUARE FOOT, U+2609: SUN, U+23DB: FUSE, and U+23DA: EARTH GROUND to represent various types of devices is not entirely semantically appropriate. May I suggest an SVG-based approach instead? Still, your "HTML images" are are always fascinating to see. My all-time favourite is blogs.msdn.com/.../10556421.aspx.

  10. cheong00 says:

    @viila: Yes. And btw, there are sorts of things that you don't want to do on flash drives, like storing files with frequent and rapid read/write operations. If you're asking users to select drive for such action, it's a good idea to remove those undesired candidates from the list presented to users.

  11. Remo kid says:

    Every drive is removable if you pull hard enough.

  12. J. Daniel Smith says:

    Is this documented anywhere else?  SHDESCRIPTIONID says nothing about the registry, nor does SHGetDataFromIDList().  Maybe the trail of breadcrumbs is (much) longer?

Comments are closed.

Skip to main content