VB.NET下获取系统图标
2006-04-24 12:45
477 查看
在这里用到一个API函数
Public Declare Function SHGetFileInfo Lib "shell32" ( _
ByVal pszPath As String, _
ByVal dwFileAttributes As Integer, _
ByRef sfi As SHFILEINFO, _
ByVal cbsfi As Integer, _
ByVal uFlags As Integer) As Integer
'获取图标()
Dim ic2 As Icon
Dim HR_Small As Integer
Dim shfi_Small As New SHFILEINFO
HR_Small = SHGetFileInfo(strfile, 0, shfi_Small, Marshal.SizeOf(shfi_Small), SHGFI.SMALLICON Or SHGFI.ICON)
'strfile是要获取图标的文件的路径,可以是文件夹,也可以是文件.
Try
ic2 = Icon.FromHandle(shfi_Small.hIcon)
SmallImage.Images.Add(ic2) '把获得的图片装在ImageList里
Catch ex As Exception
MsgBox(ex.ToString())
End Try
以后显示的时候再来ImageList里来取就是了
Public Declare Function SHGetFileInfo Lib "shell32" ( _
ByVal pszPath As String, _
ByVal dwFileAttributes As Integer, _
ByRef sfi As SHFILEINFO, _
ByVal cbsfi As Integer, _
ByVal uFlags As Integer) As Integer
'获取图标()
Dim ic2 As Icon
Dim HR_Small As Integer
Dim shfi_Small As New SHFILEINFO
HR_Small = SHGetFileInfo(strfile, 0, shfi_Small, Marshal.SizeOf(shfi_Small), SHGFI.SMALLICON Or SHGFI.ICON)
'strfile是要获取图标的文件的路径,可以是文件夹,也可以是文件.
Try
ic2 = Icon.FromHandle(shfi_Small.hIcon)
SmallImage.Images.Add(ic2) '把获得的图片装在ImageList里
Catch ex As Exception
MsgBox(ex.ToString())
End Try
以后显示的时候再来ImageList里来取就是了
相关文章推荐
- VB.Net 获取当前系统的时间分割符
- C#/VB.net/VB 获取系统时间
- VB.NET系统托盘图标实例
- VB.NET下用FSO(文件系统对象模型)实现获取硬盘信息
- [VB.NET]如何将图标放在系统托盘上
- VB.NET下用FSO(文件系统对象模型)实现获取硬盘信息
- VB.NET获取系统当前精确时间(毫秒级)
- vb.net获取程序图标
- VB.NET获取系统当前精确时间(毫秒级)
- [VB.NET]在系统栏显示图标
- VB.NET 获取电脑属性(硬盘ID、硬盘容量、Cpu序列号、MAC地址、系统类型)
- vb.net获取系统信息
- VB.Net 获取或者转换时间不受系统时间格式影响
- vb.net 获取系统特殊文件夹位置
- [VB.NET源码]22_系统栏图标控件
- VB.net 2008实例:读写注册表与获取系统信息
- VB.Net 获取或者转换时间不受系统时间格式影响
- C#/VB.NET 获取电脑属性(硬盘ID、硬盘容量、Cpu序列号、MAC地址、系统类型)
- VB.Net 获取当前系统的时间分割符
- VB.NET获取文件默认图标的方法