In the most common cases, you can use the extracted icon bitmap data using the Icon.ToBitmap () method. You can save this image in different formats. However, it is rather difficult to save the icon as a "true" .ico file .
The problem is that the built-in encoders for the icon have no image in .Net. Thus, by default, the result was saved as a low-color image. If this is not acceptable, MS is advised to save the original bitmap image data as .ico manually. I suggest you use the IconLib library that already performs this task:
Icon icon = Icon.ExtractAssociatedIcon(@"C:\Windows\System32\notepad.exe"); MultiIcon mIcon = new MultiIcon(); SingleIcon sIcon = mIcon.Add("notepad"); sIcon.CreateFrom(icon.ToBitmap(), IconOutputFormat.Vista); sIcon.Save(@"c:\notepad.ico");
source share