找回密码
 加入
搜索
查看: 3822|回复: 14

[图形处理] 【已解决】想写一个读取DLL文件里面的图标出来

 火.. [复制链接]
发表于 2015-11-22 18:44:00 | 显示全部楼层 |阅读模式
本帖最后由 cfanpc 于 2015-12-7 09:18 编辑

如下图,是在帮助文件中看到的图片。没有头绪,如何下手。。。。。求A大或者高手写一个。。。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
发表于 2015-11-22 20:39:00 | 显示全部楼层
 楼主| 发表于 2015-11-23 11:01:47 | 显示全部楼层
我要读取DLL里面的图标,和我的截图一样,不是写入DLL文件
发表于 2015-11-23 11:06:24 | 显示全部楼层
回复 3# cfanpc
_WinAPI_LoadShell32Icon
发表于 2015-11-23 12:11:31 | 显示全部楼层
本帖最后由 gyhhi 于 2015-11-23 12:12 编辑

dll文件路径你知道的,索引号例如-25,你也应该知道的。下面是一个例子,
#AutoIt3Wrapper_icon=C:\Windows\system32\SHELL32.dll|-25
发表于 2015-11-24 19:34:06 | 显示全部楼层
#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] = 0 Then Return SetError(1)
        _GUICtrlListView_BeginUpdate($hListView)
        For $i = 0 To $iTN[0] - 1
                _GUIImageList_AddIcon($hImage, $sDllFile, $i, 1)
                _GUICtrlListView_AddItem($hListView, $i, $i)
        Next
        _GUICtrlListView_EndUpdate($hListView)
EndFunc   ;==>_ListViewLoadIcon
发表于 2015-11-24 19:47:36 | 显示全部楼层
回复 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,就返回文件中的图标总数
发表于 2015-11-26 09:40:55 | 显示全部楼层
回复 6# afan

a大的东西非常给力!
 楼主| 发表于 2015-12-5 16:02:26 | 显示全部楼层
谢了  非常感谢
 楼主| 发表于 2015-12-5 16:02:35 | 显示全部楼层
谢了  非常感谢
 楼主| 发表于 2015-12-5 16:07:34 | 显示全部楼层
编辑里面的分类没有已解决啊  怎么弄啊
发表于 2015-12-5 16:17:06 | 显示全部楼层
编辑里面的分类没有已解决啊  怎么弄啊
cfanpc 发表于 2015-12-5 16:07


在标题前面手动添加
发表于 2015-12-5 17:21:09 | 显示全部楼层
好像记得帮助文档中有,,楼上的也不错
发表于 2015-12-5 17:26:50 | 显示全部楼层
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
#include <StaticConstants.au3>
Global $ahIcons[30], $ahLabels[30]
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
 楼主| 发表于 2015-12-7 09:18:08 | 显示全部楼层
回复 14# 樱花雪月


    你的是原形吧 非常感谢
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-4-18 09:17 , Processed in 0.089271 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表