Files
MsAddIns/MSDevTool/MSDevTool.iss
2026-02-28 21:01:57 +08:00

100 lines
3.4 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
; 脚本由 Inno Setup 脚本向导生成。
; 有关创建 Inno Setup 脚本文件的详细信息,请参阅帮助文档!
#define MyAppName "MSDevTool"
#define MyAppVersion "1.0.0.0"
#define MyAppPublisher "Zhanggg"
#define MyAppURL ""
#define MyAppExeName "MSDevTool.exe"
[Setup]
; 注意AppId 的值唯一标识此应用程序。不要在其他应用程序的安装程序中使用相同的 AppId 值。
; (若要生成新的 GUID请在 IDE 中单击 "工具|生成 GUID"。)
AppId={{AB69D818-12EA-4969-97E7-8B4F64B2391E}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
UninstallDisplayName={#MyAppName}
;DefaultDirName={code:GetInstallPath}\MSDevTool
ArchitecturesInstallIn64BitMode=x64compatible
CreateAppDir=no
LicenseFile=.\bin\Release\License.txt
InfoBeforeFile=.\bin\Release\License.txt
InfoAfterFile=.\bin\Release\License.txt
; 取消对以下行的注释以在非管理安装模式下运行(仅针对当前用户进行安装)。
PrivilegesRequired=admin
OutputDir=.\Setup
OutputBaseFilename={#MyAppName}
Compression=lzma
SolidCompression=yes
WizardStyle=modern
[Files]
;Source: ".\bin\Release\*"; DestDir: "{code:GetInstallPath}\MSDevTool"; Flags: ignoreversion(创建子文件夹) recursesubdirs(递归子文件夹) createallsubdirs
Source: ".\bin\Release\*"; DestDir: "{code:GetInstallPath}\MSDevTool"; Flags: ignoreversion recursesubdirs createallsubdirs
;Source: ".\bin\Release\Config\MSDevTool.dgnlib"; DestDir: "C:\ProgramData\Bentley\MicroStation 2024\Configuration\Organization\Dgnlib\Gui"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: ".\bin\Release\MSDevTool.cfg"; DestDir: "{code:GetInstallPath}\config\appl"; Flags: ignoreversion
; 注意:不要在任何共享系统文件上使用 "Flags: ignoreversion"
[Code]
var
GlobalInstallPath: string; // 全局变量存储安装路径
// 主检查函数:验证安装状态并获取路径
function InitializeSetup(): Boolean;
var
RootKey: Integer;
SubKeys: TArrayOfString;
i: Integer;
CurrentKey: string;
begin
Result := False;
RootKey := HKLM64;
// 检查主注册表项是否存在
if RegKeyExists(RootKey, 'SOFTWARE\Bentley\MicroStation') then
begin
// 获取所有GUID子项
if RegGetSubkeyNames(RootKey, 'SOFTWARE\Bentley\MicroStation', SubKeys) then
begin
// 遍历所有GUID子项
for i := 0 to GetArrayLength(SubKeys) - 1 do
begin
CurrentKey := 'SOFTWARE\Bentley\MicroStation\' + SubKeys[i];
// 检查是否存在安装路径参数
if RegValueExists(RootKey, CurrentKey, 'ProgramPath') and
RegQueryStringValue(RootKey, CurrentKey, 'ProgramPath', GlobalInstallPath) then
begin
Result := True;
Break; // 找到有效路径即终止循环
end;
end;
end;
end;
// 未找到有效安装
if not Result then
begin
MsgBox('未检测到 MicroStation 安装,安装程序将退出。', mbCriticalError, MB_OK);
Exit;
end;
// 额外验证目录物理存在
if not DirExists(GlobalInstallPath) then
begin
MsgBox('检测到无效安装路径:' + GlobalInstallPath, mbError, MB_OK);
Result := False;
end;
end;
// 直接返回已存储的路径
function GetInstallPath(Param: string): string;
begin
Result := GlobalInstallPath;
end;