admin 管理员组文章数量: 887021
2024年1月24日发(作者:常量定义和使用方法)
这个是源码:是在一个窗体中拖入一个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;
flags = | con | eAttributes;
SHGetFileInfo(path, 256, out info, (uint)cbFileInfo,flags);
答案补充
(ng());
(ng());
(ng());
(layName);
(Name);
}
答案补充
void Form1_DragEnter(object sender, entArgs e)
{
if (aPresent(op))
{
= ;
}
else
{
= ;
}
}
答案补充
void Form1_DragDrop(object sender, entArgs e)
{
string path
(()a(op)).GetValue(0).ToString();
=
= GetIcon(path, false).ToBitmap();
}
终于Over了,受不了问问了
版权声明:本文标题:获取exe文件 的图标 c# 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.freenas.com.cn/free/1706045814h499546.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论