【已解决】想写一个读取DLL文件里面的图标出来
本帖最后由 cfanpc 于 2015-12-7 09:18 编辑如下图,是在帮助文件中看到的图片。没有头绪,如何下手。。。。。求A大或者高手写一个。。。
http://www.autoitx.com/forum.php?mod=viewthread&tid=28551&highlight= 我要读取DLL里面的图标,和我的截图一样,不是写入DLL文件{:face (189):} 回复 3# cfanpc _WinAPI_LoadShell32Icon
本帖最后由 gyhhi 于 2015-11-23 12:12 编辑
dll文件路径你知道的,索引号例如-25,你也应该知道的。下面是一个例子,
#AutoIt3Wrapper_icon=C:\Windows\system32\SHELL32.dll|-25 #include <GuiListView.au3>
#include <GuiImageList.au3>
Local $sDllFile = 'Shell32.dll'
GUICreate('Exe、dll内所有图标及其索引')
Local $hListView = GUICtrlCreateListView('', 0, 0, 400, 400)
GUICtrlSendMsg(-1, $LVM_SETVIEW, 0, 0)
GUISetState()
_ListViewLoadIcon($hListView, $sDllFile)
While GUIGetMsg() <> -3
WEnd
Func _ListViewLoadIcon($hListView, $sDllFile, $iSize = 32)
Local $hImage = _GUIImageList_Create($iSize, $iSize, 5, 3)
_GUICtrlListView_SetImageList($hListView, $hImage, 0)
Local $iTN = DllCall('Shell32.dll', 'long', 'ExtractIcon', 'ptr', 0, 'str', $sDllFile, 'int', -1)
If $iTN = 0 Then Return SetError(1)
_GUICtrlListView_BeginUpdate($hListView)
For $i = 0 To $iTN - 1
_GUIImageList_AddIcon($hImage, $sDllFile, $i, 1)
_GUICtrlListView_AddItem($hListView, $i, $i)
Next
_GUICtrlListView_EndUpdate($hListView)
EndFunc ;==>_ListViewLoadIcon
回复 6# afan
经测试. 代码很给力!使用了系统的API ExtractIcon.
API使用及说明:
ExtractIcon
[声明]
Declare Function ExtractIcon Lib "shell32.dll" Alias "ExtractIconA" (ByVal hInst As Long, ByVal lpszExeFileName As String, ByVal nIconIndex As Long) As Long
[说明]
判断一个可执行文件或DLL中是否有图标存在,并将其提取出来
[参数表]
hInst ----------- Long,当前应用程序的实例句柄。也可用GetWindowWord函数取得拥有一个窗体或控件的实例的句柄
lpszExeFileName - String,在其中提取图标的那个程序的全名
nIconIndex ------ Long,欲获取的图标的索引。如果为-1,表示取得文件中的图标总数
[返回值]
Long,如成功,返回指向图标的句柄;如文件中不存在图标,则返回零。如果nIconIndex设为-1,就返回文件中的图标总数
回复 6# afan
a大的东西非常给力! 谢了非常感谢 谢了非常感谢 编辑里面的分类没有已解决啊怎么弄啊 {:face (319):} 编辑里面的分类没有已解决啊怎么弄啊
cfanpc 发表于 2015-12-5 16:07 http://www.autoitx.com/images/common/back.gif
在标题前面手动添加 好像记得帮助文档中有,,楼上的也不错 #include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
#include <StaticConstants.au3>
Global $ahIcons, $ahLabels
Global $iStartIndex = 1, $iCntRow, $iCntCol, $iCurIndex
Global $sFilename = @SystemDir & "\shell32.dll"
Global $iOrdinal = -1
Global $hPrev
Global $hGui, $hFile, $hFileSel, $hNext, $hToggle
Global $iMsg, $sCurFilename, $sTmpFile
$hGui = GUICreate("Icon Selector", 385, 435, @DesktopWidth / 2 - 192, _
@DesktopHeight / 2 - 235, -1, $WS_EX_ACCEPTFILES)
GUICtrlCreateGroup("", 5, 1, 375, 40)
GUICtrlCreateGroup("", 5, 50, 375, 380)
$hFile = GUICtrlCreateInput($sFilename, 12, 15, 325, 16, -1, $WS_EX_STATICEDGE)
GUICtrlSetState(-1, $GUI_DROPACCEPTED)
GUICtrlSetTip(-1, "You can drop files from shell here...")
$hFileSel = GUICtrlCreateButton("...", 345, 14, 26, 18)
$hPrev = GUICtrlCreateButton("Previous", 10, 45, 60, 24, $BS_FLAT)
GUICtrlSetState(-1, $GUI_DISABLE)
$hNext = GUICtrlCreateButton("Next", 75, 45, 60, 24, $BS_FLAT)
$hToggle = GUICtrlCreateButton("by Name", 300, 45, 60, 24, $BS_FLAT)
For $iCntRow = 0 To 4
For $iCntCol = 0 To 5
$iCurIndex = $iCntRow * 6 + $iCntCol
$ahIcons[$iCurIndex] = GUICtrlCreateIcon($sFilename, $iOrdinal * ($iCurIndex + 1), _
60 * $iCntCol + 25, 70 * $iCntRow + 80)
$ahLabels[$iCurIndex] = GUICtrlCreateLabel($iOrdinal * ($iCurIndex + 1), _
60 * $iCntCol + 11, 70 * $iCntRow + 115, 60, 20, $SS_CENTER)
Next
Next
GUISetState()
While 1
$iMsg = GUIGetMsg()
$sCurFilename = GUICtrlRead($hFile)
If $sCurFilename <> $sFilename Then
$iStartIndex = 1
$sFilename = $sCurFilename
_GUIUpdate()
EndIf
Select
Case $iMsg = $hFileSel
$sTmpFile = FileOpenDialog("Select file:", "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}", "Executables & dll's (*.exe;*.dll;*.ocx;*.icl)")
If @error Then ContinueLoop
GUICtrlSetData($hFile, $sTmpFile)
Case $iMsg = $hPrev
$iStartIndex = $iStartIndex - 30
_GUIUpdate()
Case $iMsg = $hNext
$iStartIndex = $iStartIndex + 30
_GUIUpdate()
Case $iMsg = $hToggle
If $iOrdinal = -1 Then
$iOrdinal = 1
GUICtrlSetData($hToggle, "by Ordinal")
WinSetTitle($hGui, "", "Icon Selector by Name value")
Else
$iOrdinal = -1
GUICtrlSetData($hToggle, "by Name")
WinSetTitle($hGui, "", "Icon Selector by Ordinal value")
EndIf
_GUIUpdate()
Case $iMsg = $GUI_EVENT_CLOSE
Exit
EndSelect
WEnd
Func _GUIUpdate()
For $iCntRow = 0 To 4
For $iCntCol = 0 To 5
$iCurIndex = $iCntRow * 6 + $iCntCol
GUICtrlSetImage($ahIcons[$iCurIndex], $sFilename, $iOrdinal * ($iCurIndex + $iStartIndex))
If $iOrdinal = -1 Then
GUICtrlSetData($ahLabels[$iCurIndex], -($iCurIndex + $iStartIndex))
Else
GUICtrlSetData($ahLabels[$iCurIndex], '"' & ($iCurIndex + $iStartIndex) & '"')
EndIf
Next
Next
If $iStartIndex = 1 Then
GUICtrlSetState($hPrev, $GUI_DISABLE)
Else
GUICtrlSetState($hPrev, $GUI_ENABLE)
EndIf
EndFunc ;==>_GUIUpdate
回复 14# 樱花雪月
你的是原形吧 非常感谢
页:
[1]