eJan Posted April 19, 2005 Share Posted April 19, 2005 I'm tryng to replace .ini line with new one taken from FileGetVersion, but the way I have tryed doesn't work with asterisk. In my case .ini file have to be updated with version that I dont know, and the version in .ini file too.I have tried with: $ver = ("1.2.3") ; ??$file = FileOpen("test.ini", 0)Dim $contentsWhile 1 $line = FileReadLine($file) If @error Then ExitLoop If $line = "Version=*" Then $line = "Version=" & $ver ; * (asterisk not supported) $contents = $contents & $line & @CRLFWEndFileClose($file)$file = FileOpen("test.ini", 2)FileWrite($file, $contents).ini (in my case is line 39):language_file=Version=1.2.3RunCount=15 Link to comment Share on other sites More sharing options...
Westi Posted April 19, 2005 Share Posted April 19, 2005 Line 8 doesn't work, use If StringInStr ( $line, "Version=") then Has the file sections like [General] or [Program] you should useIniRead ( "filename", "section", "key", "default" ) IniWrite ( "filename", "section", "key", "value" ) Link to comment Share on other sites More sharing options...
eJan Posted April 19, 2005 Author Share Posted April 19, 2005 Thanks Westi, it works great!IniRead ( "filename", "section", "key", "default" ) IniWrite ( "filename", "section", "key", "value" )Now it looks like: Func _IniWrite() $regpath = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Maxthon", "UninstallString") $string = StringLeft($regpath, StringInStr($regpath, '\', 0, -1) - 1) $exe = $string & "\Maxthon.exe" $file = FileGetVersion($exe) $exever = StringLeft($file, StringInStr($file, '.', 0, -1) - 1) IniWrite($ini1, "Settings", "Version", $exever)EndFunc Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now