The Local State
configuration file of Chrome is in the JSON format.
The Inno Setup does not support the JSON on its own. You can try to hack the file manually using a simple string manipulation.
But I'd recommend you to use some 3rd party library for parsing JSON, like TLama's Inno JSON Config library.
The code can be like below.
The code add/sets this key in the JSON. I hope this is, what you are after.
"protocol_handler": {
"excluded_schemes": {
"myprotocol": true
}
}
[Files]
Source: "JSONConfig.dll"; Flags: dontcopy
[code]
function JSONQueryBoolean(FileName, Section, Key: WideString;
Default: Boolean; var Value: Boolean): Boolean;
external 'JSONQueryBoolean@files:jsonconfig.dll stdcall';
function JSONWriteBoolean(FileName, Section, Key: WideString;
Value: Boolean): Boolean;
external 'JSONWriteBoolean@files:jsonconfig.dll stdcall';
procedure EnableChromeProtocol(Protocol: string);
var
FileName: WideString;
BoolValue: Boolean;
begin
FileName := ExpandConstant('{localappdata}') + '\Google\Chrome\User Data\Local State';
Log('Chrome local state config file: ' + FileName);
if JSONQueryBoolean(
FileName, 'protocol_handler.excluded_schemes', Protocol, False, BoolValue) then
begin
if BoolValue then
begin
Log('Protocol is enabled');
end
else
begin
Log('Protocol is disabled');
end;
end
else
begin
Log('Protocol not configured');
BoolValue := False;
end;
if not BoolValue then
begin
if JSONWriteBoolean(FileName, 'protocol_handler.excluded_schemes', Protocol, True) then
begin
Log('Protocol enabled');
end
else
begin
Log('Protocol enabling failed');
end;
end;
end;
procedure CurStepChanged(CurStep: TSetupStep);
begin
if CurStep = ssInstall then
begin
EnableChromeProtocol('myprotocol');
end;
end;
The code requires the Unicode version of Inno Setup.
See also Inno Setup: Working with JSON.
There's also an alternative implementation, the JsonParser.