Code:
#define MyAppName "RAR Component"
[Setup]
AppName=RAR Component TEST PACKAGE
AppVerName=RAR Component 1.0
DefaultDirName={localappdata}\Delphi Components\RAR
DefaultGroupName=RAR Component
OutputBaseFilename=RAR Component 1.0
Compression=lzma2
[Dirs]
Name: "{app}"; Permissions: users-modify;
Tasks: "d2022"; Name: "{commondocs}\Embarcadero\Studio\20.0\Bpl";
Tasks: "d2022"; Name: "{commondocs}\Embarcadero\Studio\20.0\Dcp";
[Tasks]
Name: "d2022"; Description: "Delphi XE10.3 Rio"; Check: "DELPHI('D103')";
[Types]
;Name: "full"; Description: "Full installation" ;
;Name: "custom"; Description: "Custom installation";Flags: iscustom
[-code-] // veranderd anders werkt the Tag niet goed :)
function GetRegistryfor(CEdition:String) : string;
var Edition : String;
begin
if cEdition='D103' then Edition:='Software\Embarcadero\BDS\20.0';
Result := Edition;
end;
function RemoveSlashUDF(cPath:String):String;
begin
If Copy(cPath,Length(cPath),1) = '\' then cPath := Copy(cPath,1,Length(cPath)-1);
Result := cPath;
end;
function GetRoot(cEdition:String):String;
var RValue, retVal: String;
begin
if RegQueryStringValue(HKEY_CURRENT_USER, GetRegistryfor(cEdition) , 'RootDir', RValue) then
begin
RValue := RemoveSlashUDF(RValue);
retVal := RValue ;
end;
Result := retVal;
end;
function Compile32(cEdition:String):String;
var RValue, retVal: String;
begin
if RegQueryStringValue(HKEY_CURRENT_USER, GetRegistryfor(cEdition) , 'RootDir', RValue) then
begin
retVal := RemoveSlashUDF(RValue) + '\bin\dcc32.exe';
if cEdition='D103' then createdir(ExpandConstant('{app}') + '\D103\');
end;
Result := retVal;
end;
function Compile64(cEdition:String):String;
var RValue, retVal: String;
begin
if RegQueryStringValue(HKEY_CURRENT_USER, GetRegistryfor(cEdition) , 'RootDir', RValue) then
begin
retVal := RemoveSlashUDF(RValue) + '\bin\dcc64.exe';
if cEdition='D103' then createdir(ExpandConstant('{app}') + '\D103\Win64');
end;
Result := retVal;
end;
function DELPHI(cEdition:String):Boolean;
var RValue: String;
retVal: Boolean;
begin
if RegQueryStringValue(HKEY_CURRENT_USER, GetRegistryfor(cEdition) , 'RootDir', RValue) then
begin
retVal := FileExists(RemoveSlashUDF(RValue) + '\bin\dcc32.exe');
end;
Result := retVal;
end;
function ExpandBPLDCP(cEdition: String; cBPLDCP:String): String;
begin
if cEdition = 'D103' then
Result := ExpandConstant('{commondocs}') + '\Embarcadero\Studio\20.0\' + cBPLDCP;
end;
function ExpandBDSCOMMONDIR_DCP(cEdition: String): String;
begin
Result := ExpandBPLDCP(cEdition,'Dcp');
end;
function UpdateLibPath(cVersion: String; cRegKey : String) : String;
var Searchstring : String;
PATH : String;
begin
if cVersion='D103' then Searchstring:=';' + ExpandConstant('{app}') + '\D103';
//Searchstring:=';' + ExpandConstant('{app}') + '\source';
if RegQueryStringValue(HKCU, cRegKey, 'Search Path', PATH) then
begin
StringChangeEx(PATH, Searchstring, '', True);
StringChangeEx(PATH, ';;', ';', True);
RegWriteStringValue(HKCU, cRegKey, 'Search Path', PATH);
end;
end;
function NeedsAddPath(cEdition: string; Param: string): boolean;
var
OrigPath: string;
Edition : string;
begin
if cEdition='D103' then Edition:='Software\Embarcadero\BDS\20.0\Library\Win32';
if cEdition='D10364' then Edition:='Software\Embarcadero\BDS\20.0\Library\Win64';
Param:= ExpandConstant('{app}')+Param;
if not RegQueryStringValue(HKCU, Edition,'Search Path', OrigPath)
then begin
Result := True;
exit;
end;
Result := Pos(';' + Param + ';', ';' + OrigPath + ';') = 0;
end;
function NeedSearchPath(cEdition: string): string;
var
OrigPath: string;
Edition : string;
begin
if cEdition='D103' then Edition:='Software\Embarcadero\BDS\20.0\Library\Win32';
if cEdition='D10364' then Edition:='Software\Embarcadero\BDS\20.0\Library\Win64';
RegQueryStringValue(HKCU, Edition,'Search Path', OrigPath);
Result :=OrigPath;
end;
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
begin
case CurUninstallStep of
usPostUninstall:
begin
UpdateLibPath('D103' ,'Software\Embarcadero\BDS\20.0\Library\Win32');
UpdateLibPath('D103' ,'Software\Embarcadero\BDS\20.0\Library\Win64');
end;
end;
end;
function ExpandBDSCOMMONDIR_BPL(cEdition: String): String;
begin
WizardForm.ProgressGauge.Position := WizardForm.ProgressGauge.Position + 1;
Result := ExpandBPLDCP(cEdition,'Bpl');
end;
function ResetProgressBar(nCount:Integer):Boolean;
begin
WizardForm.ProgressGauge.Position := 0;
WizardForm.ProgressGauge.Max := nCount;
Result := True;
end;
function PackageInfo(cMsg:String):Boolean;
Begin
WizardForm.FileNameLabel.Caption := 'Compiling and installing: '+cMsg + ' ...';
Result := True;
End;
[Components]
Name: "crar"; Description: "RAR Component"; Types: full
[Files]
Components: "crar"; Source: "RAR\*"; DestDir: "{app}"; MinVersion: 0.0,5.0; Flags: recursesubdirs
[Registry]
; Adding the bpl file to the component package
Root: HKCU; Subkey: "Software\My Company\My Program\Settings"; ValueType: string; ValueName: "InstallPath"; ValueData: "{app}"
Root: HKCU; Subkey: "{code:GetRegistryfor|D103}\Known Packages"; Components: "crar"; ValueName: "{code:ExpandBDSCOMMONDIR_BPL|D103}\RARComponentDesign260.bpl"; ValueType: String; ValueData: "RAR Component support"; Tasks: "d2022"; MinVersion: 0.0,5.0; Flags: uninsdeletevalue
; Add the folder to the search path
Root: HKCU; Subkey: "{code:GetRegistryfor|D103}\Library\Win32"; Components: "crar"; ValueName: "Search Path"; ValueType: String; ValueData: "{olddata};$(MYSOFT)\RAR\D103"; Tasks: "d2022"; Check: NeedsAddPath('D103', '$(MYSOFT)\RAR\D103') ; MinVersion: 0.0,5.0;
Root: HKCU; Subkey: "{code:GetRegistryfor|D103}\Library\Win64"; Components: "crar"; ValueName: "Search Path"; ValueType: String; ValueData: "{olddata};$(MYSOFT)\RAR\D103\Win64"; Tasks: "d2022"; Check: NeedsAddPath('D10364', '$(MYSOFT)\RAR\D103\Win64') ; MinVersion: 0.0,5.0;
Root: HKCU; Subkey: "{code:GetRegistryfor|D103}\Library\Win32"; Components: "crar"; ValueName: "Search Path"; ValueType: String; ValueData: "{olddata};{app}\D103"; Tasks: "d2022"; Check: NeedsAddPath('D103', '\D103') ; MinVersion: 0.0,5.0;
Root: HKCU; Subkey: "{code:GetRegistryfor|D103}\Library\Win64"; Components: "crar"; ValueName: "Search Path"; ValueType: String; ValueData: "{olddata};{app}\D103\Win64"; Tasks: "d2022"; Check: NeedsAddPath('D10364', '\D103\Win64') ; MinVersion: 0.0,5.0;
Root: HKCU; Subkey: "Software\Embarcadero\BDS\20.0\Globals"; ValueName: "ForceEnvOptionsUpdate"; ValueType: String; ValueData: "1"; Tasks: "D2022"
Root: HKCU; Subkey: "Software\Embarcadero\BDS\20.0\Environment Variables"; ValueName: "MYSOFT"; ValueType: String; ValueData: "{localappdata}\Delphi Components"; Tasks: "D2022"
[Run]
Filename: "compiler"; Check: "ResetProgressBar(2)"; Tasks: "d2022"; StatusMsg: "Compiling Delphi XE10.3 Rio package"; Flags: runhidden skipifdoesntexist
Filename: "{code:Compile32|D103}"; Check: "PackageInfo('RAR\Packages\RAD Studio XE10.3\RARComponent.dpk')"; Parameters: "-B ""{app}\Packages\RAD Studio XE10.3\RARComponent.dpk"" -Q -I""{code:Needsearchpath|D103}"" -LE""{code:ExpandBDSCOMMONDIR_BPL|D103}"" -LN""{code:ExpandBDSCOMMONDIR_DCP|D103}"" -NU""{app}\D103"" -NS""System;Xml;Data;Datasnap;Web;Soap;Winapi;System.Win;Data.Win;Web.Win;Soap.Win;Bde;Vcl;Vcl.Imaging;Vcl.Touch;Vcl.Samples;Vcl.Shell;"""; WorkingDir: "{app}\Source" ; Tasks: "d2022"; MinVersion: 0.0,5.0; Flags: runhidden;
Filename: "{code:Compile32|D103}"; Check: "PackageInfo('RAR\Packages\RAD Studio XE10.3\RARComponentDesign.dpk')"; Parameters: "-B ""{app}\Packages\RAD Studio XE10.3\RARComponentDesign.dpk"" -Q -I""{code:Needsearchpath|D103}"" -LE""{code:ExpandBDSCOMMONDIR_BPL|D103}"" -LN""{code:ExpandBDSCOMMONDIR_DCP|D103}"" -NU""{app}\D103"" -NS""System;Xml;Data;Datasnap;Web;Soap;Winapi;System.Win;Data.Win;Web.Win;Soap.Win;Bde;Vcl;Vcl.Imaging;Vcl.Touch;Vcl.Samples;Vcl.Shell;"""; WorkingDir: "{app}\Source" ; Tasks: "d2022"; MinVersion: 0.0,5.0; Flags: runhidden;
Filename: "{code:Compile64|D103}"; Check: "PackageInfo('RAR\Packages\RAD Studio XE10.3\RARComponent.dpk')"; Parameters: "-B ""{app}\Packages\RAD Studio XE10.3\RARComponent.dpk"" -Q -I""{code:Needsearchpath|D103}\Win64"" -LE""{code:ExpandBDSCOMMONDIR_BPL|D103}\Win64"" -LN""{code:ExpandBDSCOMMONDIR_DCP|D103}\Win64"" -NU""{app}\D103\Win64"" -NS""System;Xml;Data;Datasnap;Web;Soap;Winapi;System.Win;Data.Win;Web.Win;Soap.Win;Bde;Vcl;Vcl.Imaging;Vcl.Touch;Vcl.Samples;Vcl.Shell;"""; WorkingDir: "{app}\Source" ; Tasks: "d2022"; MinVersion: 0.0,5.0; Flags: runhidden;
[Icons]
[UninstallDelete]
Type: filesandordirs; Name: "{app}\D103"
Type: files; Name: "{app}\*.*"
Type: dirifempty; Name: "{app}"
;Deleting BPL and DCP
Type: files; Name: "{commondocs}\Embarcadero\Studio\20.0\Bpl\rarcompo*.bpl"
Type: files; Name: "{commondocs}\Embarcadero\Studio\20.0\Dcp\rarcompo*.dcp"
Type: files; Name: "{commondocs}\Embarcadero\Studio\20.0\Bpl\Win64\rarcompo*.bpl"
Type: files; Name: "{commondocs}\Embarcadero\Studio\20.0\Dcp\Win64\rarcompo*.dcp"
Bookmarks