zoukankan
html css js c++ java
如何获取文件在系统中的图标?
public
class
SysIO2
{
public
SysIO2()
{
}
private
const
uint
SHGFI_ICON
=
0x100
;
private
const
uint
SHGFI_LARGEICON
=
0x0
;
private
const
uint
SHGFI_SMALLICON
=
0x1
;
public
const
uint
SHGFI_USEFILEATTRIBUTES
=
0x10
;
[DllImport(
"
kernel32.dll
"
)]
internal
static
extern
void
ExitProcess(
int
a);
[DllImport(
"
shell32.dll
"
)]
private
static
extern
IntPtr SHGetFileInfo(
string
pszPath,
uint
dwFileAttributes,
ref
SHFILEINFO psfi,
uint
cbSizeFileInfo,
uint
uFlags);
[StructLayout(LayoutKind.Sequential)]
private
struct
SHFILEINFO
{
public
IntPtr hIcon;
public
IntPtr iIcon;
public
uint
dwAttributes;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst
=
260
)]
public
string
szDisplayName;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst
=
80
)]
public
string
szTypeName;
}
/**/
///
<summary>
///
获取指定文件(或者扩展名)和系统关联的小图标
///
</summary>
///
<param name="strExtension">
文件名,或者文件扩展名(.bmp等等)
</param>
///
<returns></returns>
internal
static
Icon GetSmallIcon(
string
strExtension)
{
string
strFileName
=
Path.GetExtension(strExtension);
if
(strFileName
==
""
)
{
strFileName
=
strExtension;
}
IntPtr hImgSmall;
SHFILEINFO shinfo
=
new
SHFILEINFO();
hImgSmall
=
SHGetFileInfo(strFileName,
0
,
ref
shinfo, (
uint
)Marshal.SizeOf(shinfo), SHGFI_ICON
|
SHGFI_SMALLICON
|
SHGFI_USEFILEATTRIBUTES);
Icon myIcon
=
System.Drawing.Icon.FromHandle(shinfo.hIcon);
return
myIcon;
}
/**/
///
<summary>
///
获取指定文件(或者扩展名)和系统关联的大图标
///
</summary>
///
<param name="strExtension">
文件名,或者文件扩展名(.bmp等等)
</param>
///
<returns></returns>
internal
static
Icon GetLargeIcon(
string
strExtension)
{
string
strFileName
=
Path.GetExtension(strExtension);
if
(strFileName
==
""
)
{
strFileName
=
strExtension;
}
IntPtr hImgLarge;
SHFILEINFO shinfo
=
new
SHFILEINFO();
hImgLarge
=
SHGetFileInfo(strFileName,
0
,
ref
shinfo, (
uint
)Marshal.SizeOf(shinfo), SHGFI_ICON
|
SHGFI_LARGEICON
|
SHGFI_USEFILEATTRIBUTES);
Icon myIcon
=
System.Drawing.Icon.FromHandle(shinfo.hIcon);
return
myIcon;
}
}
查看全文
相关阅读:
Change MYSQL data directory
Docker distrubution in django
mongo&node
理解Docker单机容器网络
auto dock
django_restframework_angularjs
Javascript异步编程的4种方法
DockerProblem
Javascript面向对象编程
scrapy post请求 multipart/form-data
原文地址:https://www.cnblogs.com/dreign/p/627146.html
最新文章
Halum UVA
[CEOI2008]order BZOJ1391 网络流
CF431D Random Task 二分+数位dp
CF431C k-Tree dp
CF431B Shower Line
2017ACM/ICPC亚洲区沈阳站-重现赛(感谢东北大学)
[TJOI2013]松鼠聚会 BZOJ 3170
【模板】最小费用最大流
谁能赢呢? BZOJ 2463
Codeforces 279D The Minimum Number of Variables 状压dp
热门文章
Codeforces 959F Mahmoud and Ehab and yet another xor task 线性基 (看题解)
Codeforces 258D Little Elephant and Broken Sorting (看题解) 概率dp
Codeforces 439E Devu and Birthday Celebration 容斥
Codeforces 755F PolandBall and Gifts bitset + 二进制优化多重背包
Codeforces 1109D Sasha and Interesting Fact from Graph Theory (看题解) 组合数学
Codeforces 840C On the Bench dp
Codeforces 840D Expected diameter of a tree 分块思想
Codeforces 750E New Year and Old Subsequence 线段树 + dp (看题解)
Codeforces 852I Dating 树上莫队
.mysqldump
Copyright © 2011-2022 走看看