保存信息到配置文件问题
如上图,将一个软件或任意程序拖到此框,就会显示出具体路径,能不能将获得的路径,直接自动保存到my.ini
文件里。my.ini格式是这样的
my.ini文件里有A1和A2两处,获得的路径信息将写入A1处(d:\qq2008\qq.exe),而A2处能不能自动取掉最后的qq.exe(d:\qq2008),最终就成了上图这样。
源码:
#include <GUIConstantsEx.au3>
Opt('MustDeclareVars', 1)
Example()
Func Example()
Local $file, $btn, $msg
GUICreate(" My GUI input acceptfile", 320, 120, @DesktopWidth / 2 - 160, @DesktopHeight / 2 - 45, -1, 0x00000018); WS_EX_ACCEPTFILES
$file = GUICtrlCreateInput("", 10, 5, 300, 20)
GUICtrlSetState(-1, $GUI_DROPACCEPTED)
GUISetState()
$msg = 0
While $msg <> $GUI_EVENT_CLOSE
$msg = GUIGetMsg()
Select
Case $msg = $file
ExitLoop
Case $file
EndSelect
WEnd
EndFunc
[ 本帖最后由 botanycc 于 2008-6-9 20:34 编辑 ] 下次请使用含义清楚的标题
#include <GUIConstantsEx.au3>
;~ Opt('MustDeclareVars', 1)
Example()
Func Example()
Local $file, $btn, $msg
GUICreate(" My GUI input acceptfile", 320, 120, @DesktopWidth / 2 - 160, @DesktopHeight / 2 - 45, -1, 0x00000018); WS_EX_ACCEPTFILES
$file = GUICtrlCreateInput("", 10, 5, 300, 20)
GUICtrlSetState(-1, $GUI_DROPACCEPTED)
GUISetState()
$msg = 0
While 1
$msg = GUIGetMsg()
Select
Case $msg = $file
ExitLoop
Case $msg =$GUI_EVENT_CLOSE
$tmp=GUICtrlRead($file)
IniWrite("aa.ini","sect","a1",$tmp)
IniWrite("aa.ini","sect","a2",StringLeft($tmp,StringInStr($tmp,'\',0,-1)))
GUIDelete()
MsgBox(0,"pcbar","文件信息已保存至aa.ini")
ShellExecute("aa.ini")
Exit
EndSelect
WEnd
EndFunc ;==>Example 嗯,知道了,多谢版主大人 啊,我用最笨的方法多加了几行,怎么有错误啊。
只能从最后先拖放,其次2和1处,能不能打乱顺序都可以啊。还有就是打开后,不执行拖放 直接退出程序,那配置文件里原先的信息就会被清空的,这个怎么解决好呢?
#include <GUIConstantsEx.au3>
Example()
Func Example()
Local $file, $btn, $msg
GUICreate(" My", 320, 120, @DesktopWidth / 2 - 160, @DesktopHeight / 2 - 45, -1, 0x00000018)
$file = GUICtrlCreateInput("", 10, 5, 300, 20)
GUICtrlSetState(-1, $GUI_DROPACCEPTED)
$file2 = GUICtrlCreateInput("", 10, 40, 300, 20)
GUICtrlSetState(-1, $GUI_DROPACCEPTED)
$file3 = GUICtrlCreateInput("", 10, 75, 300, 20)
GUICtrlSetState(-1, $GUI_DROPACCEPTED)
GUISetState()
$msg = 0
While 1
$msg = GUIGetMsg()
Select
Case $msg = $file
ExitLoop
Case $msg =$GUI_EVENT_CLOSE
$tmp=GUICtrlRead($file)
$tmp2=GUICtrlRead($file2)
$tmp3=GUICtrlRead($file3)
IniWrite("aa.ini","sect","a1",$tmp)
IniWrite("aa.ini","sect","a2",StringLeft($tmp,StringInStr($tmp,'\',0,-1)))
IniWrite("aa.ini","sect","a3",$tmp2)
IniWrite("aa.ini","sect","a4",StringLeft($tmp2,StringInStr($tmp2,'\',0,-1)))
IniWrite("aa.ini","sect","a5",$tmp3)
IniWrite("aa.ini","sect","a6",StringLeft($tmp3,StringInStr($tmp3,'\',0,-1)))
GUIDelete()
Exit
EndSelect
WEnd
EndFunc if $tmp<>"" then ..... 什么?不太明白 {:face (319):}学习下~~赚点金币。。。 学习了,,刚了学到配置。。
页:
[1]