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

如何对ini中表写入数据!

[复制链接]
发表于 2008-8-26 23:57:51 | 显示全部楼层 |阅读模式
我想对C:\windows\system32\OemInfo.ini中的Support Information
下Line1=下写数据,
必需是回车就向第二行Line2=下写数据



#include <GUIConstants.au3>

GUICreate("OEM修改器", 380 ,430)
GUICtrlCreateGroup("", 5, 1, 370, 425)
GUICtrlCreateLabel("注册到:", 170, 20)
$wink1 = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion", "RegisteredOwner")
$Input = GUICtrlCreateInput("", 220, 15, 145,20)
  GUICtrlSetData($Input, ($wink1))
$wink2 = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion", "RegisteredOrganization")
$Input2 = GUICtrlCreateInput("", 220, 40, 145,20)
  GUICtrlSetData($Input2, ($wink2))
$wink3 = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion", "ProductId")
$Input3 = GUICtrlCreateInput("", 220, 65, 145,20)
  GUICtrlSetData($Input3, ($wink3))
$wink4 = IniRead("C:\windows\system32\OemInfo.ini", "General", "Manufacturer", "")
  GUICtrlCreateLabel("支持信息:", 200, 220)
$Input4 = GUICtrlCreateInput("", 220, 235, 145,20)
    GUICtrlSetData($Input4, ($wink4))
$wink5 = IniRead("C:\windows\system32\OemInfo.ini", "General", "Model", "")
  $Input5 = GUICtrlCreateInput("", 220, 255, 145,20)
    GUICtrlSetData($Input5, ($wink5))
$wink6 = IniRead("C:\windows\system32\OemInfo.ini", "Support Information", "Line1", "")
$Input6 = GUICtrlCreateEdit("", 10, 280, 360 , 100)
        GUICtrlSetData($Input6, ($wink6))
        
GUICtrlCreateButton("删除oem信息",90, 390 ,90 ,30)
$Button2 = GUICtrlCreateButton("确定",200, 390 ,70 ,30)
$Button3 = GUICtrlCreateButton("返回",290, 390 ,70 ,30)
  
GUISetState(@SW_SHOW)
While 1
        $nmsg = GUIGEtMsg()
        Select
                Case $nmsg = $GUI_EVENT_CLOSE
                        ExitLoop
                Case $nmsg = $Button3
                Exit
        Case $nmsg = $Button2
                $okInput = GUICtrlRead ($Input)
                RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion", "RegisteredOwner", "REG_SZ", $okInput)
                $okInput2 = GUICtrlRead ($Input2)
                RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion", "RegisteredOrganization", "REG_SZ", $okInput2)
                $okInput3 = GUICtrlRead ($Input3)
                RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion", "ProductId", "REG_SZ", $okInput3)
                $okInput4 = GUICtrlRead ($Input4)
                $sIni =  @SystemDir & "\oeminfo.ini"
                IniWrite("C:\windows\system32\OemInfo.ini", "General", "Manufacturer",$okInput4)
                $okInput5 = GUICtrlRead ($Input5)
                IniWrite("C:\windows\system32\OemInfo.ini", "General", "Model",$okInput5)

                $okInput6 = GUICtrlRead ($Input6)
                IniWrite("C:\windows\system32\OemInfo.ini", "Support Information", "Line1", $okInput6)
        EndSelect
WEnd


[ 本帖最后由 sliqi 于 2008-9-24 15:04 编辑 ]
 楼主| 发表于 2008-9-18 20:44:45 | 显示全部楼层
三恨来看看吧!!!
如果实现在回车后就像第二行写数据。
发表于 2008-9-18 21:06:36 | 显示全部楼层
没看懂
发表于 2008-9-18 21:12:49 | 显示全部楼层
好像大概看懂了。。
这样不行吗?

IniWrite("C:\windows\system32\OemInfo.ini", "Support Information", "Line1", $okInput6)
IniWrite("C:\windows\system32\OemInfo.ini", "Support Information", "Line2", $okInput6)
IniWrite("C:\windows\system32\OemInfo.ini", "Support Information", "Line3", $okInput6)
发表于 2008-9-18 22:43:27 | 显示全部楼层
我也看懂了,
第一行加
#include <array.au3>
倒数第三行换为以下内容:

$t = StringSplit($okinput6, @LF)
                        For $i = 1 To UBound($t) - 1
                                $t[$i] = 'Line' & $i & '=' & $t[$i]
                        Next
                        ;如有必要,请加上  IniDelete("C:\windows\system32\OemInfo.ini", "Support Information")
                        IniWriteSection("C:\windows\system32\OemInfo.ini", "Support Information", _ArrayToString($t, @LF, 1))
 楼主| 发表于 2008-9-23 23:05:39 | 显示全部楼层
非常感谢二位,
我用三恨的方法想把
IniWrite("C:\windows\system32\OemInfo.ini", "Support Information", "Line1", $okInput6)

读到 第23行的 $Input6 = GUICtrlCreateEdit("", 10, 280, 360 , 100)

多加几条Line2都不行,也是只显示一行。
我用

$wink6 = IniReadSection("C:\windows\system32\oeminfo.ini", "Support Information")
For $i = 1 To $wink6[0][0]
         GUICtrlSetData($Input6, ($wink6[$i][1]))
    Next

GUICtrlSetData只能显示最后一行。
 楼主| 发表于 2008-9-24 15:04:05 | 显示全部楼层
解决了,很感谢二位。

$wink6 = IniReadSection("C:\windows\system32\oeminfo.ini", "Support Information")
    For $i = 1 To $wink6[0][0]
GUICtrlSetData($Input6, $wink6[$i][1]&@CRLF,"1")
    Next
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-7 05:17 , Processed in 0.073620 second(s), 19 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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