找回密码
 加入
搜索
查看: 1207|回复: 3

读取ini关键值,循环出错.好奇怪

[复制链接]
发表于 2009-7-18 22:01:27 | 显示全部楼层 |阅读模式
本帖最后由 qq4045728 于 2009-7-19 09:24 编辑
$i = IniReadSection(@WindowsDir&"\d.ini","reg")
Const $n=$i
For $i =1 to $n Step 1
     $reg = IniRead(@WindowsDir&\"d.ini","reg",$i,"")
         RunWait($reg)
Next
----------------------------------------------------------
[reg]
1=a.exe
2=b.exe
3=c.exe
为什么只将 a.exe循环运行了3次其他的确不运行??代码哪里有问题了.如果定义$i=3  确可以将1=a.exe,2=b.exe,3=c.exe都运行  

---------------------------------------------------------


$q = IniReadSection(@WindowsDir&"\&"\d.ini","one")
const $w=$q
for $e = 1 to $w Step 1
     $run= IniRead(@WindowsDir&"\d.ini","one",$e,"")
     RegWrite("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce",$e,"REG_SZ",$run)
Next
-------------------------------------
[one]
1=a.exe
2=b.exe
3=c.exe
这里确只将a.exe 写入到注册表了. 如果定义$q=3  确可以将1=a.exe,2=b.exe,3=c.exe都写到注册表     
-------------------------------------
以上的问题好奇怪...


晕了换了iniread命令还是不行..
发表于 2009-7-18 23:32:40 | 显示全部楼层
第一,楼主难道没发现你2个变量名是一样的吗?
第二,IniReadSection中变量的个数是存在变量的第[0][0]个元素中的,该好好看看帮助文档
 楼主| 发表于 2009-7-19 09:15:10 | 显示全部楼层
2# 大绯狼


上面我只是举一个例子!!!!
 楼主| 发表于 2009-7-19 09:24:31 | 显示全部楼层
$var = IniReadSection("C:\Temp\myfile.ini", "section2")
If @error Then
    MsgBox(4096, "", "Error occurred, probably no INI file.")
Else
    For $i = 1 To $var[0][0]
        MsgBox(4096, "", "Key: " & $var[$i][0] & @CRLF & "Value: " & $var[$i][1])
    Next
EndIf
   解决了!!
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-3 00:40 , Processed in 0.079969 second(s), 19 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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