获取exe文件 的图标 c#

获取exe文件 的图标 c#


2024年4月27日发(作者:)

这个是源码:是在一个窗体中拖入一个exe文件可以获取,你可以修改一下

[DllImport("")]//引入""

private static extern int SHGetFileInfo(string pszPath, uint dwFileAttributes, out

SHFILEINFO psfi, uint cbfileInfo, SHGFI uFlags);

[StructLayout(tial)]

struct SHFILEINFO

{

public IntPtr hIcon;

public int iIcon;

public uint attributes;

[MarshalAs(, SizeConst = 260)]

public string szDisplayName;

[MarshalAs(, SizeConst = 80)]

public string szTypeName;

public SHFILEINFO(bool b)

{

hIcon = ;

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 = (info);

SHGFI flags;

if (small)

{

flags = | con | eAttributes;

}

else

{

flags = | con | eAttributes;

}

SHGetFileInfo(path, 256, out info, (uint)cbFileInfo, flags);

return ndle();

}

答案补充

public static void GetIcon(string path)

{

SHFILEINFO info = new SHFILEINFO(true);

int cbFileInfo = (info);

SHGFI flags;


发布者:admin,转转请注明出处:http://www.yc00.com/news/1714205235a2401804.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信