找回密码
 加入
搜索
查看: 2803|回复: 4

[系统综合] 搜索数组中包含某个字符

  [复制链接]
发表于 2015-4-21 10:07:21 | 显示全部楼层 |阅读模式
#include <Array.au3>

Dim $i = 1, $RegN[1]
;遍历已安装程序
Const $root = 'HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall'
While 1
        $nMsg = GUIGetMsg()
        
        $v = RegEnumKey($root, $i)
        If @error <> 0 Then
                ExitLoop
        Else
                $n = RegRead($root & '\' & $v, 'DisplayName')
                $u = RegRead($root & '\' & $v, 'UninstallString')
                If $n <> '' And $u <> '' Then
                        _ArrayAdd($RegN, $n)
                        
                EndIf
        EndIf
        $i += 1
WEnd

Local $aiResult = _ArrayBinarySearch($RegN, "Microsoft")
 _ArrayDisplay($RegN, "第一次")
_ArrayDisplay($aiResult, "第二次")
搜索“Uninstall”键值下面是否包含 “Microsoft”
我用了 _ArrayBinarySearch 貌似不行。
发表于 2015-4-21 13:13:16 | 显示全部楼层
_ArrayBinarySearch只能用在一维数组
 楼主| 发表于 2015-4-21 22:11:19 | 显示全部楼层
新手,一直未解决, 哪位前辈能指点一二,想解决,又解决不了。只能厚脸问问大家了。
发表于 2015-4-21 22:51:33 | 显示全部楼层
http://www.autoitx.com/thread-47731-1-1.html,你在这里问了同样的问题,总不会让大家帮你解决所有的事情吧,该自己动手就自己动手,论坛虽说是开放的,但不是挨宰的
 楼主| 发表于 2015-4-21 23:08:11 | 显示全部楼层
已经解决了。感谢前辈的关注。
While 1
        $nMsg = GUIGetMsg()
        
        $v = RegEnumKey($root, $i)
        If @error <> 0 Then
                ExitLoop
        Else
                $n = RegRead($root & '\' & $v, 'DisplayName')
                $u = RegRead($root & '\' & $v, 'UninstallString')
                If $n <> '' And $u <> '' Then
                         
                        $hzh = StringInStr($n, "c++")
                        If $hzh > 0 Then
                                

                                

                                _ArrayAdd($RegN, $n)
                                
                        EndIf
                        
                EndIf
        EndIf
        $i += 1
WEnd




_ArrayDisplay($RegN, "第一次")
直接在开始就判断,合适才丢进数组里面。
这样最优吧。
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-1 19:51 , Processed in 0.077692 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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