如何获取文件的图标
论坛上好像只有获取exe文件图标的帖子可是我想获取txt,jpg,doc等各种文件的那个小图标,请问下有什么方法呀 求高手指点啊 这些信息都在注册表中,自己多琢磨下 _WinAPI_ShellExtractAssociatedIcon ;#Include <APIConstants.au3>
#Include <GUIListView.au3>
#Include <GUIImageList.au3>
#Include <WinAPIEx.au3>
Opt('MustDeclareVars', 1)
Global $hForm, $Msg, $Button, $ListView, $hImageList, $hIcon, $Key, $Count = 1, $First = False
Global $tSHFILEINFO = DllStructCreate($tagSHFILEINFO)
Dim $Ext =
RegRead('HKCR\.x', '')
While 1
$Key = RegEnumKey('HKCR', $Count)
If @error Then
ExitLoop
EndIf
If StringLeft($Key, 1) = '.' Then
RegRead('HKCR\' & $Key, '')
If Abs(@error) <> 1 Then
$Ext += 1
If $Ext > UBound($Ext) - 1 Then
ReDim $Ext
EndIf
$Ext[$Ext] = $Key
EndIf
$First = 1
Else
If $First Then
ExitLoop
EndIf
EndIf
$Count += 1
WEnd
$hForm = GUICreate('MyGUI', 280, 391)
$ListView = GUICtrlCreateListView('', 10, 10, 260, 344, BitOR($LVS_DEFAULT, $LVS_NOCOLUMNHEADER), $WS_EX_CLIENTEDGE)
_GUICtrlListView_SetExtendedListViewStyle($ListView, BitOR($LVS_EX_DOUBLEBUFFER, $LVS_EX_INFOTIP))
_GUICtrlListView_InsertColumn($ListView, 0, '', 238)
$hImageList = _GUIImageList_Create(16, 16, 5, 1)
_GUICtrlListView_SetImageList($ListView, $hImageList, 1)
$Button = GUICtrlCreateButton('OK', 105, 361, 70, 23)
For $i = 1 To $Ext
$hIcon = _WinAPI_ShellExtractAssociatedIcon($Ext[$i], 1)
_GUIImageList_ReplaceIcon($hImageList, -1, $hIcon)
_GUICtrlListView_AddItem($ListView, $Ext[$i], $i - 1)
_WinAPI_DestroyIcon($hIcon)
Next
GUISetState()
While 1
$Msg = GUIGetMsg()
Switch $Msg
Case -3, $Button
ExitLoop
EndSwitch
WEnd
谢谢netegg的分享哈 解决方案太犀利了 学习了,谢谢5楼
netegg 发表于 2014-1-25 14:04 http://www.autoitx.com/images/common/back.gif
我为什么都是错误啊 netegg的代码很犀利~! 回复 5# netegg
蛋神果然很是牛叉啊!
页:
[1]