我使用Eclipse和Inno安装程序来创建一个小应用程序。编译是用Ant编写的。一切都很好,我可以找到生成默认.iss的位置,将它放在我的Eclipse中,并对其进行修改,使我的安装程序注入注册表项,从而使支持我的应用程序自定义URL。
(project/build/package/windows/myapp.iss
,添加了[Registry]
部件)
它工作,在IE和边缘,但不幸的是,不适用于Chrome,因为谷歌决定不跟随注册表,当涉及到自定义URL.
你们知道是否可以通过Inno安装程序安装Chrome的自定义URL吗?
到目前为止,我所知道的是,我们需要mod %localappdata%/Google/Chrome/User Data/Local State
来添加协议,但是它是否可以通过Inno设置完成呢?
发布于 2015-11-01 10:58:37
Chrome的Local State
配置文件采用JSON格式。
Inno设置本身不支持JSON。您可以尝试使用简单的字符串操作手动破解该文件。
但是我建议您使用第三方库来解析JSON,比如TLama JSON Config库。
代码可以如下所示。
代码add/设置JSON中的这个键。我希望这是你想要的。
"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;
代码需要Inno安装程序的Unicode版本。
还有一个替代的实现,JsonParser。
https://stackoverflow.com/questions/33460915
复制相似问题