[DllImport("shell32.dll", EntryPoint = "ExtractIconEx")]
public static extern int ExtractIconEx(string lpszFile, int nIconIndex, IntPtr[] phiconLarge, IntPtr[] phiconSmall, int nIcons);
int numIcons = ExtractIconEx(filename, -1, null, null, 0); // Number of icons
ExtractIconEx(filename, 0, largeIcon, smallIcon, numIcons); // Usage