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

[AU3基础] [已解决]从DLL中获取图标的问题

 火.. [复制链接]
发表于 2010-9-24 10:09:24 | 显示全部楼层 |阅读模式
本帖最后由 skyfree 于 2010-9-25 21:15 编辑

一般来说使用DLL中的图标文件是用GUICtrlSetImage函数实现,设定要读取的DLL,以及图标的编号就可以了,如GUICtrlSetImage($IconCtrlHdl,"x:\xx\xx.dll",1001),其中$IconCtrlHdl为图标空间的句柄。

但最近我从注册表中读出了这样的图标信息,如:"%systemroot%\system32\imageres.dll,-93",很显然,图标文件位于C:\Windows\System32\imageres.dll中,但“-93”究竟是不是图标的编号?

尝试用过GUICtrlSetImage(C:\Windows\System32\imageres.dl,"x:\xx\xx.dll",-93)和GUICtrlSetImage(C:\Windows\System32\imageres.dl,"x:\xx\xx.dll",93),即使用和不使用“-”,发现读出的图标不是我所需要的。那究竟想“-93”这样的编号,究竟指的是什么,还请各位帮忙分析。

十分感谢!

评分

参与人数 1金钱 +10 收起 理由
afan + 10 感谢主动将修改帖子分类为[已解决],请继续 ...

查看全部评分

发表于 2010-9-24 10:49:48 | 显示全部楼层
$aRet = _PickIconDlg(@SystemDir & "\shell32.dll", 8, WinGetHandle(""))
If Not @error Then MsgBox(64, "Results", StringFormat("IconFile Selected: %s\nIconID Selected: %i", $aRet[0], $aRet[1]))

Func _PickIconDlg($sFileName, $nIconIndex=0, $hWnd=0)
    Local $nRet, $aRetArr[2]
    
    $nRet = DllCall("shell32.dll", "int", "PickIconDlg", _
        "hwnd", $hWnd, _
        "wstr", $sFileName, "int", 1000, "int*", $nIconIndex)
    
    If Not $nRet[0] Then Return SetError(1, 0, -1)
    
    $aRetArr[0] = $nRet[2]
    $aRetArr[1] = $nRet[4]
    
    Return $aRetArr
EndFunc

评分

参与人数 1金钱 +20 收起 理由
afan + 20

查看全部评分

发表于 2010-9-24 10:57:20 | 显示全部楼层
这个应该可以帮助你。
x:\xxxx\AutoIt3\Examples\GUI\Advanced\enumicons.au3
发表于 2010-9-24 11:09:30 | 显示全部楼层
回复 1# skyfree
该编号应该是与TraySetIcon相对应的。
发表于 2010-9-24 11:51:29 | 显示全部楼层
本帖最后由 lixiaolong 于 2010-9-24 12:15 编辑

GUICtrlSetImage(-1, "C:\Windows\System32\imageres.dll", -93)

这个“-93“就是,首先建立一个文件夹
在文件夹上点右键,打开属性,选[自定义]
点[更改图标],点[浏览] 选C:\Windows\System32\imageres.dll
然后出现很多图标,第一个就是 -1 ,从上往下数,-1 -2 -3 ,,,,
第93个图标就是 -93
#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3>

Opt('MustDeclareVars', 1)

Example()

Func Example()
        Local $msg

        GUICreate("My GUI") ; will create a dialog box that when displayed is centered

        GUICtrlCreateButton("my picture button", 10, 20, 40, 40, $BS_ICON)
        GUICtrlSetImage(-1, "C:\Windows\System32\imageres.dll", -93)

        GUISetState()

        ; Run the GUI until the dialog is closed
        While 1
                $msg = GUIGetMsg()

                If $msg = $GUI_EVENT_CLOSE Then ExitLoop
        WEnd
EndFunc   ;==>Example
忘说了,我干才试了一下,如果使用的系统是XP,在imageres.dll里找图标就不正常
Vista和Win7可以正常找到需要的图标

本帖子中包含更多资源

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

×

评分

参与人数 1金钱 +30 收起 理由
afan + 30

查看全部评分

发表于 2010-9-24 14:47:32 | 显示全部楼层
谢谢各们大侠,学习了。
 楼主| 发表于 2010-9-24 22:31:08 | 显示全部楼层
十分感谢各位的解答,认真学习了
发表于 2010-9-24 22:38:50 | 显示全部楼层
来学习了!!!!!!!
发表于 2010-9-25 10:20:04 | 显示全部楼层
这个LZ是自由天空的SKYFREE吗?
发表于 2010-9-25 20:52:11 | 显示全部楼层
欢迎skyfree到来!
发表于 2010-9-25 21:06:56 | 显示全部楼层
解决了的话还请前辈修改标题,加注“已解决”
发表于 2010-10-8 13:28:20 | 显示全部楼层
估计不是吧?
发表于 2012-2-12 18:34:24 | 显示全部楼层
学习了各位大大
发表于 2015-2-1 23:50:02 | 显示全部楼层
学习下DLL,对这方面的知识了解甚少
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-6-13 09:50 , Processed in 0.090495 second(s), 26 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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