From the hard way:
Icon ico = System.Drawing.Icon.ExtractAssociatedIcon(filePath);
From dll resource:
// Process handle IntPtr processHandle = System.Diagnostics.Process.GetCurrentProcess().Handle; // DLL path string DLLPath = Path.Combine(Environment.SystemDirectory, "shell32.dll"); // Open folder icon index int iconIndex = 4; // Extract icon System.IntPtr oPtr = ExtractIcon(processHandle, DLLPath, iconIndex); Icon oIcon = Icon.FromHandle(oPtr);
From:
C # Retrieving system icons and icons
source share