#define MyAppName "上华环境工程设计系统Revit插件" #define VERSION "2026" #define APPVER "V7.0" #define MyAppPublisher "ShangHuaSoft, Inc." #define MyAppURL "http://www.shanghuasoft.com/" #define DateTime GetDateTimeString('(yyyy.mm.dd-hh.nn)', '-', ':') #define INIDateTime GetDateTimeString('yyyymmddhhnn', '', '') #define PACKAGE_PATH "..\Original-File\SHRevitPP3DAddin" #define AddinName "SHRevitPP3DAddin" #define DllName "SHRevitPP3DAddin" [Setup] AppId={{EE02A82D-43CA-4E31-8BFE-F00E21147B74} AppName={#MyAppName} AppVersion={#VERSION} AppPublisher={#MyAppPublisher} DefaultDirName= {sd}\ShangHuaSoft\{#AddinName}-{#VERSION}\ DefaultGroupName=SHRevitPlug OutputBaseFilename={#AddinName}{#APPVER}{#DateTime} Compression=lzma2 SolidCompression=yes DisableDirPage=no OutputDir=..\Output-File DisableProgramGroupPage=yes PrivilegesRequired=admin ArchitecturesInstallIn64BitMode=x64 UsePreviousTasks=no UsePreviousAppDir=no [Languages] Name: "Chinese"; MessagesFile: "compiler:Languages\ChineseSimplified.isl" [Types] Name: Revit ;Description:"ShangHua-RevitPlug"; Flags: iscustom [Components] Name: Revit2018; Description: "安装Revit2018插件"; Types: Revit; Check : hasRevitVersion('2018') Name: Revit2019; Description: "安装Revit2019插件"; Types: Revit; Check : hasRevitVersion('2019') Name: Revit2020; Description: "安装Revit2020插件"; Types: Revit; Check : hasRevitVersion('2020') [dirs] Name:"{app}\2018\Equipment" Name:"{app}\2019\Equipment" Name:"{app}\2020\Equipment" [Files] Source: "{#PACKAGE_PATH}\2018\*"; DestDir: "{app}\2018";Flags:ignoreversion recursesubdirs createallsubdirs;Excludes:"Equipment,revitapi.dll,revitapiui.dll"; Components: Revit2018 Source: "{#PACKAGE_PATH}\2019\*"; DestDir: "{app}\2019";Flags:ignoreversion recursesubdirs createallsubdirs;Excludes:"Equipment,revitapi.dll,revitapiui.dll"; Components: Revit2019 Source: "{#PACKAGE_PATH}\2020\*"; DestDir: "{app}\2020";Flags:ignoreversion recursesubdirs createallsubdirs;Excludes:"Equipment,revitapi.dll,revitapiui.dll"; Components: Revit2020 Source: "{#PACKAGE_PATH}\bitanswer\*"; DestDir: "{app}\2018";Flags:ignoreversion recursesubdirs createallsubdirs; Components: Revit2018 Source: "{#PACKAGE_PATH}\bitanswer\*"; DestDir: "{app}\2019";Flags:ignoreversion recursesubdirs createallsubdirs; Components: Revit2019 Source: "{#PACKAGE_PATH}\bitanswer\*"; DestDir: "{app}\2020";Flags:ignoreversion recursesubdirs createallsubdirs; Components: Revit2020 Source: "{#PACKAGE_PATH}\{#AddinName}.addin"; DestDir: "{commonappdata}\Autodesk\Revit\Addins\2018\";Flags:ignoreversion; Components: Revit2018 Source: "{#PACKAGE_PATH}\{#AddinName}.addin"; DestDir: "{commonappdata}\Autodesk\Revit\Addins\2019\";Flags:ignoreversion; Components: Revit2019 Source: "{#PACKAGE_PATH}\{#AddinName}.addin"; DestDir: "{commonappdata}\Autodesk\Revit\Addins\2020\";Flags:ignoreversion; Components: Revit2020 [Code] function hasRevitVersion(const AVersion: string): Boolean; var bHaveKey : Boolean; rootkey: string; path:string; Names: TArrayOfString; I: Integer; begin rootkey := 'SOFTWARE\Autodesk\Revit\' + AVersion; bHaveKey := RegKeyExists(HKEY_LOCAL_MACHINE, rootkey); if (bHaveKey = false) then begin Result := false; Exit; end; if RegGetSubkeyNames(HKEY_LOCAL_MACHINE, rootkey, Names) = false then begin Result := false; Exit; end; for I := 0 to GetArrayLength(Names)-1 do begin if RegQueryStringValue(HKEY_LOCAL_MACHINE, rootkey + '\' + Names[I], 'InstallationLocation', path) then begin if Fileexists(path + '\revit.exe') then begin Result := true; Exit; end; end; end; end; procedure SetInnerTxtToXML(const AFileName, APath, AValue: string); var XMLNode: Variant; XMLDocument: Variant; begin XMLDocument := CreateOleObject('Msxml2.DOMDocument.6.0'); try XMLDocument.async := False; XMLDocument.load(AFileName); if (XMLDocument.parseError.errorCode <> 0) then MsgBox('The XML file could not be parsed. ' + XMLDocument.parseError.reason, mbError, MB_OK) else begin XMLDocument.setProperty('SelectionLanguage', 'XPath'); XMLNode := XMLDocument.selectSingleNode(APath); XMLNode.text := AValue; XMLDocument.save(AFileName); end; except MsgBox('An error occured!' + #13#10 + GetExceptionMessage, mbError, MB_OK); end; end; function InitializeSetup(): Boolean; begin if (hasRevitVersion('2018') = false) and (hasRevitVersion('2019') = false) and (hasRevitVersion('2020') = false) then begin MsgBox('本地没有找到 Revit 2018,2019,2020的安装。', mbInformation, MB_OK); Result := false; end else begin Result := true; end; end; procedure CurStepChanged(CurStep: TSetupStep); begin if CurStep=ssInstall then begin end; if CurStep=ssPostinstall then begin if (hasRevitVersion('2018')) then SetInnerTxtToXML( ExpandConstant('{commonappdata}\Autodesk\Revit\Addins\2018\{#AddinName}.addin') , '//RevitAddIns/AddIn[@Type=''Application'']/Assembly' , ExpandConstant('{app}\2018\{#DllName}.dll')); if (hasRevitVersion('2019')) then SetInnerTxtToXML( ExpandConstant('{commonappdata}\Autodesk\Revit\Addins\2019\{#AddinName}.addin') , '//RevitAddIns/AddIn[@Type=''Application'']/Assembly' , ExpandConstant('{app}\2019\{#DllName}.dll')); if (hasRevitVersion('2020')) then SetInnerTxtToXML( ExpandConstant('{commonappdata}\Autodesk\Revit\Addins\2020\{#AddinName}.addin') , '//RevitAddIns/AddIn[@Type=''Application'']/Assembly' , ExpandConstant('{app}\2020\{#DllName}.dll')); end; if CurStep=ssDone then //MsgBox('软件成功安装', mbInformation, MB_OK); end;