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

[AU3基础] FileOpenDialog选择文件再iniwrite失败?

[复制链接]
发表于 2011-1-17 12:33:39 | 显示全部楼层 |阅读模式
我用FileOpenDialog选择文件,再用iniwrite写入ini文件,iniread时显示正常,但是打开ini文件,里面的值为什么没有更改?
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
;~ Opt("GUIOnEventMode", 1);gui使用onevent模式
#Region ### START Koda GUI section ### Form=
;~ $exename=IniRead("config.ini","path","exename","")
$Form1 = GUICreate("Form1", 260, 80)

$Input1 = GUICtrlCreateInput("", 10, 10, 250, 25)
$Button1 = GUICtrlCreateButton("选择文件", 10, 40, 70, 25)
$Button2 = GUICtrlCreateButton("写入INI", 90, 40, 70, 25)
$Button3 = GUICtrlCreateButton("读取INI", 170, 40, 70, 25)

;~ GUICtrlSetOnEvent($Button1, "file")
;~ GUICtrlSetOnEvent($Button2, "write")
;~ GUICtrlSetOnEvent($Button3, "read")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button1
                        file()
                Case $Button2
                        write()
                Case $Button3
                        read()
        EndSwitch
WEnd

Func file()
        $findgamea = FileOpenDialog("选择游戏主程序", "", "游戏主程序 (*.exe)", GUICtrlRead($Input1), "D2loader.exe", $Form1)
        If Not FileExists($findgamea) = 0 Then
                GUICtrlSetData($Input1, $findgamea)
        EndIf
EndFunc   ;==>file

Func write()
        $a = GUICtrlRead($Input1)
        IniWrite("config.ini", "path", "exename", $a)
        MsgBox(0,"","写入完成")
EndFunc   ;==>write

Func read()
        $b = IniRead("config.ini", "path", "exename", "")
        MsgBox(0, "", $b)
EndFunc   ;==>read
发表于 2011-1-17 12:42:13 | 显示全部楼层
IniWrite(@ScriptDir & "\config.ini", "path", "exename",  $a)
 楼主| 发表于 2011-1-17 13:38:47 | 显示全部楼层
解决,谢谢
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-18 11:38 , Processed in 0.075370 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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