c#图标提取
答案:1 悬赏:70 手机版
解决时间 2021-02-28 11:58
- 提问者网友:姑娘长的好罪过
- 2021-02-27 22:06
谁能帮我用C#写一个提取exe的ICO图标的工具!?? 万分感谢!!!! 只要C#的!!!!
最佳答案
- 五星知识达人网友:怙棘
- 2021-02-27 22:49
这个是源码:是在一个窗体中拖入一个exe文件可以获取,你可以修改一下 [DllImport("Shell32.dll")]//引入"Shell32.dll" private static extern int SHGetFileInfo(string pszPath, uint dwFileAttributes, out SHFILEINFO psfi, uint cbfileInfo, SHGFI uFlags); [StructLayout(LayoutKind.Sequential)] struct SHFILEINFO { public IntPtr hIcon; public int iIcon; public uint attributes; [MarshalAs(UnmanagedType.LPStr, SizeConst = 260)] public string szDisplayName; [MarshalAs(UnmanagedType.LPStr, SizeConst = 80)] public string szTypeName; public SHFILEINFO(bool b) { hIcon = IntPtr.Zero; iIcon = 0; attributes = 0; szDisplayName = ""; szTypeName = ""; } } private enum SHGFI { SmallIcon = 0x00000001, LargeIcon = 0x00000020, Icon = 0x00000100, DisplayName = 0x00000200, TypeName = 0x00000400, SysIconIndex = 0x00004000, UseFileAttributes = 0x00000010 } public static Icon GetIcon(string path, bool small) { SHFILEINFO info = new SHFILEINFO(true); int cbFileInfo = Marshal.SizeOf(info); SHGFI flags; if (small) { flags = SHGFI.Icon | SHGFI.SmallIcon | SHGFI.UseFileAttributes; } else { flags = SHGFI.Icon | SHGFI.LargeIcon | SHGFI.UseFileAttributes; } SHGetFileInfo(path, 256, out info, (uint)cbFileInfo, flags); return Icon.FromHandle(info.hIcon); }
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯