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了,受不了问问了


本文标签: 获取 常量 定义 拖入 文件