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条)