From 16384ccd013985f6f303d9a165b6fe1238ec2e2f Mon Sep 17 00:00:00 2001 From: Ansgar Becker Date: Mon, 20 Jun 2011 22:05:32 +0000 Subject: [PATCH] Allow custom portable settings filename as a command line switch. Fixes issue #2469. --- out/readme.txt | 4 ++++ source/helpers.pas | 14 ++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/out/readme.txt b/out/readme.txt index 0812f5e2..e786ead1 100644 --- a/out/readme.txt +++ b/out/readme.txt @@ -51,6 +51,7 @@ and are based on those used by the MySQL command line applications, e.g. mysqldu -p, -password Password -P, -port Port (defaults to 3306 if not given) -S, -socket Socket name (for connecting via named pipe) +--psettings Custom filename for portable settings. Ignored if file does not exist. Examples: @@ -68,6 +69,9 @@ Examples: * Open multiple .sql files in query tabs: c:\path\to\heidisql.exe fileA.sql path\to\fileB.sql fileC.sql ... +* Use custom portable settings file: + c:\path\to\heidisql.exe --psettings=c:\temp\p.txt + *** License: diff --git a/source/helpers.pas b/source/helpers.pas index 50ee9979..ad8fc522 100644 --- a/source/helpers.pas +++ b/source/helpers.pas @@ -2320,7 +2320,18 @@ const end; begin // Export registry keys and values into textfile, for portable reasons - FileName := ExtractFilePath(ParamStr(0)) + 'portable_settings.txt'; + + // Use filename from command line. If not given, use file in directory of executable. + rx := TRegExpr.Create; + rx.Expression := '^\-\-?psettings\=(.+)$'; + for i:=1 to ParamCount do begin + if rx.Exec(ParamStr(i)) then begin + Filename := rx.Match[1]; + break; + end; + end; + if Filename = '' then + Filename := ExtractFilePath(ParamStr(0)) + 'portable_settings.txt'; if not FileExists(FileName) then Exit; @@ -2380,7 +2391,6 @@ begin MainReg.OpenKeyReadOnly('\Software\'); AllKeys := TStringList.Create; MainReg.GetKeyNames(AllKeys); - rx := TRegExpr.Create; rx.Expression := '^' + QuoteRegExprMetaChars(APPNAME) + ' Portable (\d+)$'; for i:=0 to AllKeys.Count-1 do begin if not rx.Exec(AllKeys[i]) then