--------------------------------------------------------- //プログラムと同じフォルダに「C:\Windows\winhlp32.exe」の256x256アイコンを出力 using System; using System.Drawing; using System.Windows.Forms; using System.Runtime.InteropServices; using System.IO; using System.Reflection;
public class Icon256 { [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] public struct SHFILEINFO { public IntPtr hIcon; public int iIcon; public uint dwAttributes; [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)] public string szDisplayName; [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 80)] public string szTypeName; }
[DllImport("shell32.dll")] static extern int SHGetImageList(uint iImageList, ref Guid riid, out IntPtr ppv);
[DllImport("comctl32.dll", SetLastError=true)] static extern bool ImageList_DrawEx(IntPtr himl, int i, IntPtr hdcDst, int x, int y, int dx, int dy, uint rgbBk, uint rgbFg, int fStyle);