VB.net 2010 视频教程 VB.net 2010 视频教程 python基础视频教程
SQL Server 2008 视频教程 c#入门经典教程 Visual Basic从门到精通视频教程
当前位置:
首页 > VB.net教程 >
  • VB.NET下获取系统图标

在这里用到一个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里来取就是了


相关教程