vb怎样读取一个文件的图标

 我来答
硪丨暧恋
2017-05-15 · TA获得超过8980个赞
知道大有可为答主
回答量:5336
采纳率:93%
帮助的人:2154万
展开全部
'ImageList
Private Const MAX_PATH = 260
Private Const SHGFI_DISPLAYNAME = &H200 ' get display name
Private Const SHGFI_EXETYPE = &H2000 ' return exe type
Private Const SHGFI_LARGEICON = &H0 ' get large icon
Private Const SHGFI_SHELLICONSIZE = &H4 ' get shell size icon
Private Const SHGFI_SMALLICON = &H1 ' get small icon
Private Const SHGFI_SYSICONINDEX = &H4000 ' get system icondex
Private Const SHGFI_TYPENAME = &H400 ' get type name
Private Const ILD_BLEND50 = &H4
Private Const ILD_BLEND25 = &H2
Private Const ILD_TRANSPARENT = &H1
Private Const CLR_NONE = &HFFFFFFFF
Private Const CLR_DEFAULT = &HFF000000
Private Type SHFILEINFO
hIcon As Long ' : icon
iIcon As Long ' : icondex
dwAttributes As Long ' : SFGAO_ flags
szDisplayName As String * MAX_PATH ' : display name (or path)
szTypeName As String * 80 ' : type name
End Type
Private Declare Function SHGetFileInfo Lib "shell32.dll" Alias "SHGetFileInfoA" (ByVal pszPath As String, ByVal dwFileAttributes As Long, psfi As SHFILEINFO, ByVal cbFileInfo As Long, ByVal uFlags As Long) As Long
Private Declare Function ImageList_Draw Lib "comctl32.dll" (ByVal himl As Long, ByVal i As Long, ByVal hdcDst As Long, ByVal x As Long, ByVal y As Long, ByVal fStyle As Long) As Long
Private Declare Function ImageList_DrawEx Lib "comctl32.dll" (ByVal himl As Long, ByVal i As Long, ByVal hdcDst As Long, ByVal x As Long, ByVal y As Long, ByVal dx As Long, ByVal dy As Long, ByVal rgbBk As Long, ByVal rgbFg As Long, ByVal fStyle As Long) As Long
Private Sub Form_Load()

Dim hImage As Long, udtFI As SHFILEINFO
'set the graphics mode of form1 to persistent
Me.AutoRedraw = True
'get the handle of the system image list that contains the large icon images
hImage = SHGetFileInfo("c:\thefile.tst", ByVal 0&, udtFI, Len(udtFI), SHGFI_SYSICONINDEX Or SHGFI_LARGEICON)
'draw the icon (normal)
ImageList_Draw hImage, udtFI.iIcon, Me.hDC, 0, 0, ILD_TRANSPARENT
'draw the icon (blended)
ImageList_DrawEx hImage, udtFI.iIcon, Me.hDC, 32, 0, 32, 32, CLR_NONE, CLR_DEFAULT, ILD_BLEND50
End Sub
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式