找回密码
 加入
搜索
查看: 4980|回复: 2

[AU3基础] [已解决]硬件侦测比对ini内容相同但使用StringCompare的结果不同?

[复制链接]
发表于 2015-1-31 23:46:00 | 显示全部楼层 |阅读模式
本帖最后由 ticket 于 2015-2-2 09:06 编辑

硬件侦测到的和INI内容相同但使用StringCompare比对的结果不同?
使用if的方式来判别也是不同,所以只有求助家伙喔~
#include <_CompInfo.au3>

#Region ;~~ Computer Infomartion
    Local $CompInf,$Ramvr, $CPUvr,$VGAvr,$i1
    Local $CPURam
    Local $CPUInfo = ''

    $CPUInfo &= '===>CPU Information' & @CRLF
    _ComputerGetOSs($CompInf)
    $CompInf = StringSplit($CompInf[1][0], '|')
    $CPUInfo &= 'OS: ' & @TAB & @TAB & @TAB & $CompInf[1] & @CRLF

    _ComputerGetSystem($CompInf)
    $CPUInfo &= 'System: ' & @TAB & @TAB & $CompInf[1][46] & @CRLF

    _ComputerGetProcessors($CompInf)
    $CPUInfo &= 'CPU: ' & @TAB & @TAB & @TAB & $CompInf[1][0] & @CRLF
        $CPUvr =$CompInf[1][0];cpu值,要写入INI的数值

    _ComputerGetMemory($CompInf)
    For $i = 1 To $CompInf[0][0]
        $CPURam += $CompInf[$i][2]
    Next
        $CPUInfo &= 'Ram: ' & @TAB & @TAB & @TAB & Round(Number($CPURam/1024^2)) & ' MB' & @CRLF
            $Ramvr=$CPURam/1024^2;记忆值,要写入INI的数值

    _ComputerGetVideoCards($CompInf)
    For $i = 1 To $CompInf[0][0]
        $CPUInfo &= 'VGA' & $i & ': ' & @TAB & @TAB & @TAB & $CompInf[$i][0] & @CRLF
                $VGAvr =$CompInf[$i][0];VGA值,要写入INI的数值
    Next

    _ComputerGetMonitors($CompInf)
    For $i = 1 To $CompInf[0][0]
        $CPUInfo &= 'Monitor' & $i & ': ' & @TAB & @TAB & $CompInf[$i][21] & '*' & $CompInf[$i][20] & @CRLF
    Next
#EndRegion

                           IniWrite("C:\Program Files\NoDrivers\enroll.ini", "处理器", "型号",$CPUvr)
                           IniWrite("C:\Program Files\NoDrivers\enroll.ini", "记忆体", "型号",$Ramvr)
                           IniWrite("C:\Program Files\NoDrivers\enroll.ini", "显色卡", "容量",$VGAvr)

Local $ini1 = IniReadSectionNames("C:\Program Files\NoDrivers\enroll.ini");读取客编号
Local $answer[3]=[$CPUvr,$Ramvr,$VGAvr]
Local $ini2 , $is=0 ,$result



  For $i = 1 To $ini1[0]
      ; MsgBox(4096, "", "字段名:" & $ini1[$i])

             $ini2 = IniReadSection("C:\Program Files\NoDrivers\enroll.ini",$ini1[$i]);读取客编号


         For $i1 = 1 To $ini2[0][0]

                  MsgBox(4096, "", "字段名:" &   $ini2[$i1][1])


           $result = StringCompare($answer[$is], $ini2[$i1][1],1);侦测的型号和ini内的型号比对



          MsgBox(4096, "", "字段名:" &   $answer[$is]);侦测的型号
                  MsgBox(4096, "", "比对结果:" &  $result);比对相同为0不相同为1




                  $is=$is+1



             Next



  Next
我是参考下面的内容来修改的
http://www.autoitscript.com/forum/topic/29404-computer-info-udfs/
发表于 2015-2-1 12:02:53 | 显示全部楼层
把结果输出来看一下是不是有不同,在输出字符串边上加上其他字符看一下有没有空格
 楼主| 发表于 2015-2-1 16:55:28 | 显示全部楼层
本帖最后由 ticket 于 2015-2-2 09:09 编辑

我找到问题了,谢谢大大的提示,就是文字的空格问题,所以无法比对,如何要比一整句,有含空格的文字,要用IniReadSection函数
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-6 20:58 , Processed in 0.081950 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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