; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
#define MyAppName "ff-browser"
#define MyAppVersion "1.0.0.0"
#define MyAppPublisher "嘻嘻哈哈"
#define MyAppURL "https://home.firefoxchina.cn/"
#define MyAppExeName "chrome.exe"
#define MyAppAssocName MyAppName + " File"
#define MyAppAssocExt ".myp"
#define MyAppAssocKey StringChange(MyAppAssocName, " ", "") + MyAppAssocExt
#define MyIntermediaryExeName "Intermediary.exe"
[Setup]
; NOTE: The value of AppId uniquely identifies this application. Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{7FA7B9B7-F796-40AA-A0D7-3DF341B7A903}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={autopf}\{#MyAppName}
ChangesAssociations=yes
DisableProgramGroupPage=yes
; Uncomment the following line to run in non administrative install mode (install for current user only.)
;PrivilegesRequired=lowest
OutputDir=C:\Users\Administrator\Desktop\1111
OutputBaseFilename=FF
SetupIconFile=C:\Users\Administrator\Desktop\agowy-k3amy-001.ico
Compression=lzma
SolidCompression=yes
ChangesEnvironment=yes
WizardStyle=modern
[Languages]
Name: "chinesesimplified"; MessagesFile: "compiler:Languages\ChineseSimplified.isl"
[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
[Files]
Source: "C:\Users\Administrator\AppData\Local\Chromium\Application\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\Users\Administrator\AppData\Local\Chromium\Application\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: compiler:psvince.dll;Flags: dontcopy noencryption
[Registry]
Root: HKA; Subkey: "Software\Classes\{#MyAppAssocExt}\OpenWithProgids"; ValueType: string; ValueName: "{#MyAppAssocKey}"; ValueData: ""
Root: HKA; Subkey: "Software\Classes\{#MyAppAssocKey}"; ValueType: string; ValueName: ""; ValueData: "{#MyAppAssocName}"; Flags: uninsdeletevalue
Root: HKA; Subkey: "Software\Classes\{#MyAppAssocKey}\DefaultIcon"; ValueType: string; ValueName: ""; ValueData: "{app}\{#MyAppExeName},0"; Flags: uninsdeletevalue
Root: HKA; Subkey: "Software\Classes\{#MyAppAssocKey}\shell\open\command"; ValueType: string; ValueName: ""; ValueData: """{app}\{#MyAppExeName}"" ""%1"""; Flags: uninsdeletevalue
Root: HKA; Subkey: "Software\Classes\Applications\{#MyAppExeName}\SupportedTypes"; ValueType: string; ValueName: ".myp"; ValueData: ""
Root: HKCR; Subkey: "Test"; ValueType: string; ValueName: "URL Protocol"; ValueData: ""
Root: HKCR; Subkey: "Test"; ValueType: string; ValueName: ""; ValueData: "Test Protocol"; Flags: uninsdeletevalue
Root: HKCR; Subkey: "Test\DefaultIcon"; ValueType: string; ValueName: ""; ValueData: """{app}\{#MyIntermediaryExeName}"""; Flags: uninsdeletevalue
Root: HKCR; Subkey: "Test\shell"; ValueType: none; ValueName: ""; ValueData: ""
Root: HKCR; Subkey: "Test\shell\open"; ValueType: none; ValueName: ""; ValueData: ""
Root: HKCR; Subkey: "Test\shell\open\command"; ValueType: string; ValueName: ""; ValueData: """{app}\{#MyIntermediaryExeName}"" ""%1"""; Flags: uninsdeletevalue
[Icons]
Name: "{autoprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
[Run]
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent
[code]
const EnvironmentKey = 'Environment';
procedure EnvAddPath(instlPath: string);
var
Paths: string;
begin
{ 检索当前的路径 }
if not RegQueryStringValue(HKEY_CURRENT_USER, EnvironmentKey, 'Path', Paths) then
Paths := '';
if Paths = '' then
Paths := instlPath + ';'
else
begin
{ 如果已在路径中找到字符串则跳过 }
if Pos(';' + Uppercase(instlPath) + ';', ';' + Uppercase(Paths) + ';') > 0 then exit;
if Pos(';' + Uppercase(instlPath) + '\\;', ';' + Uppercase(Paths) + ';') > 0 then exit;
{ 将应用安装路径附加到路径变量的末尾 }
Log(Format('Right(Paths, 1): [%s]', [Paths[length(Paths)]]));
if Paths[length(Paths)] = ';' then
Paths := Paths + instlPath + ';' { 不要加倍';'在环境(路径)中 }
else
Paths := Paths + ';' + instlPath + ';' ;
end;
{ 覆盖(或在缺少时创建)路径环境变量 }
if RegWriteStringValue(HKEY_CURRENT_USER, EnvironmentKey, 'Path', Paths)
then Log(Format('The [%s] added to PATH: [%s]', [instlPath, Paths]))
else Log(Format('Error while adding the [%s] to PATH: [%s]', [instlPath, Paths]));
end;
procedure EnvRemovePath(instlPath: string);
var
Paths: string;
P, Offset, DelimLen: Integer;
begin
{ 如果注册表项不存在则跳过 }
if not RegQueryStringValue(HKEY_CURRENT_USER, EnvironmentKey, 'Path', Paths) then
exit;
{ 如果在路径中找不到字符串则跳过 }
DelimLen := 1; { Length(';') }
P := Pos(';' + Uppercase(instlPath) + ';', ';' + Uppercase(Paths) + ';');
if P = 0 then
begin
{ 也许 instlPath 存在于 Paths 中,但以 '\\;' 结尾 }
DelimLen := 2; { Length('\\;') }
P := Pos(';' + Uppercase(instlPath) + '\\;', ';' + Uppercase(Paths) + ';');
if P = 0 then exit;
end;
{ 确定在 Delete() 操作中从何处开始字符串子集。 }
if P = 1 then
Offset := 0
else
Offset := 1;
{ 更新路径变量 }
Delete(Paths, P - Offset, Length(instlPath) + DelimLen);
{ 覆盖路径环境变量 }
if RegWriteStringValue(HKEY_CURRENT_USER, EnvironmentKey, 'Path', Paths)
then Log(Format('The [%s] removed from PATH: [%s]', [instlPath, Paths]))
else Log(Format('Error while removing the [%s] from PATH: [%s]', [instlPath, Paths]));
end;
//安装的时候添加环境
procedure CurStepChanged(CurStep: TSetupStep);
begin
if CurStep = ssPostInstall
then EnvAddPath(ExpandConstant('{app}'));
end;
function IsModuleLoaded(modulename: String ): Boolean;
external 'IsModuleLoaded@files:psvince.dll stdcall setuponly';
//;判断进程是否存在
function IsAppRunning(const FileName : string): Boolean;
var
FSWbemLocator: Variant;
FWMIService : Variant;
FWbemObjectSet: Variant;
begin
Result := false;
try
FSWbemLocator := CreateOleObject('WBEMScripting.SWBEMLocator');
FWMIService := FSWbemLocator.ConnectServer('', 'root\CIMV2', '', '');
FWbemObjectSet := FWMIService.ExecQuery(Format('SELECT Name FROM Win32_Process Where Name="%s"',[FileName]));
Result := (FWbemObjectSet.Count > 0);
FWbemObjectSet := Unassigned;
FWMIService := Unassigned;
FSWbemLocator := Unassigned;
except
if (IsModuleLoaded(FileName)) then
begin
Result := false;
end
else
begin
Result := true;
end
end;
end;
//安装的时候判断进程是否存在
function InitializeSetup(): Boolean;
begin
Result := IsAppRunning('{#MyAppExeName}');
if Result then
begin
MsgBox('程序正在运行,请先关闭程序后再重试! ', mbError, MB_OK);
result:=false;
end
else
begin
result := true;
end;
end;
//卸载的时候判断进程是否存在
function InitializeUninstall(): Boolean;
begin
Result := IsAppRunning('{#MyAppExeName}');
if Result then
begin
MsgBox('程序正在运行,请先关闭程序后再重试! ', mbError, MB_OK);
result:=false;
end
else
begin
result := true;
end;
end;
//卸载的时候....执行某些程序....比如删除注册表 比如删除环境
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
begin
//删除环境
if CurUninstallStep = usPostUninstall
then EnvRemovePath(ExpandConstant('{app}'));
//删除注册表
if CurUninstallStep = usPostUninstall then
begin
if RegKeyExists(HKEY_CLASSES_ROOT, 'Test') then
begin
if MsgBox('您想要删除注册表吗?', mbConfirmation, MB_YESNO) = IDYES then
begin
RegDeleteKeyIncludingSubkeys(HKEY_CLASSES_ROOT, 'Test'); //删除这个还有其他的 还得继续删除
if RegKeyExists(HKEY_CURRENT_USER, 'Software\Classes\{#MyAppAssocExt}\OpenWithProgids') then
RegDeleteKeyIncludingSubkeys(HKEY_CURRENT_USER, 'Software\Classes\{#MyAppAssocExt}\OpenWithProgids');
if RegKeyExists(HKEY_CURRENT_USER, 'Software\Classes\{#MyAppAssocKey}') then
RegDeleteKeyIncludingSubkeys(HKEY_CURRENT_USER, 'Software\Classes\{#MyAppAssocExt}\OpenWithProgids');
if RegKeyExists(HKEY_CURRENT_USER, 'Software\Classes\Applications\{#MyAppExeName}\SupportedTypes') then
RegDeleteKeyIncludingSubkeys(HKEY_CURRENT_USER, 'Software\Classes\Applications\{#MyAppExeName}\SupportedTypes');
end;
end;
end;
//删除飞跨浏览器相关的用户数据文件
if CurUninstallStep = usPostUninstall then
begin
if MsgBox('您想要删除用户配置信息?', mbConfirmation, MB_YESNO) = IDYES then
begin
if FileOrDirExists(ExpandConstant('{localappdata}\FF')) then
DelTree(ExpandConstant('{localappdata}\FF'), True, True, True);
end;
end;
end;