I know i can extract a file’s icon using
using (System.Drawing.Icon sysicon = System.Drawing.Icon.ExtractAssociatedIcon(filePath))
{
icon = System.Windows.Interop.Imaging.CreateBitmapSourceFromHIcon(
sysicon.Handle,
System.Windows.Int32Rect.Empty,
System.Windows.Media.Imaging.BitmapSizeOptions.FromEmptyOptions());
}
But how can I, with no file, get the icon for a given extension?
Use the
GetFileIconmethod from this CodeProject article from Paul Ingles and pass.extas thenameparameter.The
GetFileIconmethod is a wrapper around the nativeSHGetFileInfoand copied here for illustration: