Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 57 additions & 14 deletions source/CompressPath.dpr
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ type
procedure RemoveDuplicates;
function StorePath: Integer;
procedure StoreVariables;
procedure WriteRegistry(const Name, Value: string);
procedure WriteRegistry( const xName,
xValue: string;
const xIsVariable: Boolean);
property OrgLength: Integer read FOrgLength;
property Path: TStringList read FPath;
property PathDelphi: string read FPathDelphi;
Expand Down Expand Up @@ -321,7 +323,9 @@ var
S: string;
begin
S := Path.DelimitedText;
WriteRegistry('Path', S);
WriteRegistry( 'Path',
S,
False);
result := S.Length;
end;

Expand All @@ -330,23 +334,62 @@ var
I: Integer;
begin
Variables.Sort;
for I := 0 to Variables.Count - 1 do begin
WriteRegistry(Variables.Names[I], Variables.ValueFromIndex[I]);

for I := 0 to Variables.Count - 1 do
begin
WriteRegistry( Variables.Names[ I],
Variables.ValueFromIndex[ I],
True);
end;
end;

procedure TPathCompressor.WriteRegistry(const Name, Value: string);
procedure TPathCompressor.WriteRegistry( const xName,
xValue: string;
const xIsVariable: Boolean);
var
lExistingPath: String;
begin
{$IFDEF DEBUG}
{ In DEBUG mode only show the changes that would be made to the registry.
}
Writeln(Name, '=', Value);
Exit;
{$ENDIF}
if Value.Contains('%') then
Registry.WriteExpandString(Name, Value)
if not xIsVariable or
not Registry.ValueExists( xName) then
begin
{$IFDEF DEBUG}
{ In DEBUG mode only show the changes that would be made to the registry.
}
Writeln( xName,
'=',
xValue);
Exit;
{$ENDIF}

if xValue.Contains('%') then
begin
Registry.WriteExpandString( xName,
xValue);
end
else
begin
Registry.WriteString( xName,
xValue);
end;
end
else
Registry.WriteString(Name, Value);
begin
lExistingPath := Registry.ReadString( xName);

if ( Trim( lExistingPath) <> ( xValue)) then
begin
Writeln( Format( 'Key "%s" already exists with different Path ->',
[ xName]));
Writeln( 'Value:' .PadRight( 10).PadLeft( 12) +
'"' +
lExistingPath +
'"');
Writeln( 'Default:'.PadRight( 10).PadLeft( 12) +
'"' +
xValue +
'"');
end;
end;
end;

procedure ShowHelp;
Expand Down