Getting disk and directory icons: Icon.ExtractAssociatedIcon (filePath) not working?

If the Icon.ExtractAssociatedIcon(filePath) only way to get badges in .NET && is if it doesn't work for disks and directories (right?), Then how are you going to get badges for them?

In other words, I would like

foreach (string driveName in Directory.GetLogicalDrives())
//if (System.IO.Directory.Exists(driveName))
{
    using (System.Drawing.Icon systemIcon = System.Drawing.Icon.ExtractAssociatedIcon(driveName))
    { ... }
}

^ this obviously does not work (only works for files)

I am not sure if System.IO.Directory.Exists(file)this is the correct way to detect the presence of disks ...

+5
source share
1 answer

To do this from a .NET application, you will need to P / call the function from the Windows API (defined in ). SHGetFileInfoshell32.dll

, , : #

+11

All Articles