11#define MyAppName " asmr-dl-ng"
2- #define MyAppVersion " 1.0.2 "
2+ #define MyAppVersion " 1.0.3 "
33#define MyAppPublisher " daydreamer-json"
44#define MyAppURL " https://github.com/daydreamer-json/asmr-dl-ng"
55#define MyAppExeName " asmr-dl-ng.exe"
@@ -12,7 +12,8 @@ AppVerName={#MyAppName}
1212AppPublisher = {#MyAppPublisher}
1313AppPublisherURL = {#MyAppURL}
1414AppSupportURL = {#MyAppURL}
15- AppUpdatesURL = {#MyAppURL}
15+ AppUpdatesURL = {#MyAppURL}
16+ AppCopyright = (C) {#MyAppPublisher} and contributors
1617DefaultDirName = {autopf}\{#MyAppName }
1718UninstallDisplayIcon = {app} \{#MyAppExeName}
1819; "ArchitecturesAllowed=x64compatible" specifies that Setup cannot run
@@ -32,7 +33,8 @@ PrivilegesRequiredOverridesAllowed=dialog
3233OutputDir = D:\Applications\GitHub\Repository\asmr-dl-ng \build
3334OutputBaseFilename = asmr-dl-ng_win_x64_{#MyAppVersion}_setup
3435SolidCompression = yes
35- WizardStyle = modern dynamic windows11
36+ WizardStyle = modern dynamic windows11
37+ ChangesEnvironment = true
3638
3739[Languages]
3840Name : " english" ; MessagesFile : " compiler:Default.isl"
@@ -63,86 +65,84 @@ Name: "spanish"; MessagesFile: "compiler:Languages\Spanish.isl"
6365Name : " swedish" ; MessagesFile : " compiler:Languages\Swedish.isl"
6466Name : " tamil" ; MessagesFile : " compiler:Languages\Tamil.isl"
6567Name : " turkish" ; MessagesFile : " compiler:Languages\Turkish.isl"
66- Name : " ukrainian" ; MessagesFile : " compiler:Languages\Ukrainian.isl"
68+ Name : " ukrainian" ; MessagesFile : " compiler:Languages\Ukrainian.isl"
69+
70+ [Tasks]
71+ Name : " AddToPath" ; Description : " Add app directory to PATH environment variable" ; Flags : checkedonce
6772
6873[Files]
6974Source : " D:\Applications\GitHub\Repository\asmr-dl-ng\build\asmr-dl-ng\{#MyAppExeName}" ; DestDir : " {app} " ; Flags : ignoreversion
7075Source : " D:\Applications\GitHub\Repository\asmr-dl-ng\build\asmr-dl-ng\*" ; DestDir : " {app} " ; Flags : ignoreversion recursesubdirs createallsubdirs
7176
72- [Icons]
73- Name : " {group} \{#MyAppName}" ; Filename : " {app} \{#MyAppExeName}"
77+ ; [Icons]
78+ ; Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
7479
75- [Registry]
76- ; Add the application's directory to the user's PATH
77- Root : HKCU; Subkey : " Environment" ; ValueType : expandsz ; ValueName : " Path" ; ValueData : " {olddata};{app} " ; Check : NeedsAddPath(ExpandConstant(' {app} ' ))
78- ; Add the application's directory to the system's PATH if installing for all users
79- Root : HKLM; Subkey : " SYSTEM\CurrentControlSet\Control\Session Manager\Environment" ; ValueType : expandsz ; ValueName : " Path" ; ValueData : " {olddata};{app} " ; Check : IsAdminInstallMode and NeedsAddPath(ExpandConstant(' {app} ' ))
80-
81- [Code]
82- var
83- PathNeedsUpdate: boolean;
84-
85- function InitializeSetup (): Boolean;
86- begin
87- PathNeedsUpdate := false;
88- Result := true;
89- end ;
90-
91- function StrSplit (Text: String; Separator: String): TArrayOfString;
92- var
93- i, p: Integer;
94- Dest: TArrayOfString;
95- begin
96- i := 0 ;
97- repeat
98- SetArrayLength(Dest, i + 1 );
99- p := Pos(Separator, Text);
100- if p > 0 then
101- begin
102- Dest[i] := Copy(Text, 1 , p - 1 );
103- Text := Copy(Text, p + Length(Separator), Length(Text));
104- i := i + 1 ;
105- end
106- else
107- begin
108- Dest[i] := Text;
109- Text := ' ' ;
110- end ;
111- until Length(Text) = 0 ;
112- Result := Dest;
113- end ;
114-
115- function NeedsAddPath (Param: string): boolean;
116- var
117- OldPath: string;
118- OldPathArr: TArrayOfString;
119- I: Integer;
120- Exists: boolean;
121- begin
122- if not RegQueryStringValue(HKEY_CURRENT_USER, ' Environment' , ' Path' , OldPath) then
123- begin
124- if not RegQueryStringValue(HKEY_LOCAL_MACHINE, ' SYSTEM\CurrentControlSet\Control\Session Manager\Environment' , ' Path' , OldPath) then
125- begin
126- OldPath := ' ' ;
127- end ;
128- end ;
129-
130- // Normalize the path to remove any trailing backslash
131- if (Length(Param) > 0 ) and (Param[Length(Param)] = ' \' ) then
132- Param := Copy(Param, 1 , Length(Param) - 1 );
133-
134- Exists := false;
135- OldPathArr := StrSplit(OldPath, ' ;' );
136- for I := 0 to GetArrayLength(OldPathArr) - 1 do
137- begin
138- if CompareText(OldPathArr[I], Param) = 0 then
139- begin
140- Exists := true;
141- break;
142- end ;
143- end ;
144-
145- Result := not Exists;
146- if Result then
147- PathNeedsUpdate := true;
148- end ;
80+ [Registry]
81+ ; Add the application's directory to the user's PATH
82+ Root : HKCU; Subkey : " Environment" ; ValueType : expandsz ; ValueName : " Path" ; ValueData : " {olddata};{app} " ; Check : (not IsAdminInstallMode) and WizardIsTaskSelected(' AddToPath' ) and NeedsAddPath(' {app} ' )
83+ ; Add the application's directory to the system's PATH if installing for all users
84+ Root : HKLM; Subkey : " SYSTEM\CurrentControlSet\Control\Session Manager\Environment" ; ValueType : expandsz ; ValueName : " Path" ; ValueData : " {olddata};{app} " ; Check : IsAdminInstallMode and WizardIsTaskSelected(' AddToPath' ) and NeedsAddPath(' {app} ' )
85+
86+ [Code]
87+ function NeedsAddPath (Param: string): boolean;
88+ var
89+ OrigPath: string;
90+ ParamExpanded: string;
91+ begin
92+ ParamExpanded := ExpandConstant(Param);
93+
94+ if not RegQueryStringValue(HKEY_LOCAL_MACHINE,
95+ ' SYSTEM\CurrentControlSet\Control\Session Manager\Environment' ,
96+ ' Path' , OrigPath)
97+ then begin
98+ Result := True;
99+ exit;
100+ end ;
101+
102+ Result := Pos(' ;' + UpperCase(ParamExpanded) + ' ;' , ' ;' + UpperCase(OrigPath) + ' ;' ) = 0 ;
103+
104+ if Result = True then
105+ Result := Pos(' ;' + UpperCase(ParamExpanded) + ' \;' , ' ;' + UpperCase(OrigPath) + ' ;' ) = 0 ;
106+ end ;
107+
108+ procedure RemovePath (RootKey: Integer; SubKey, ValueName, PathToRemove: string);
109+ var
110+ Paths: string;
111+ P: Integer;
112+ begin
113+ if not RegQueryStringValue(RootKey, SubKey, ValueName, Paths) then
114+ Exit;
115+
116+ P := Pos(' ;' + UpperCase(PathToRemove) + ' ;' , ' ;' + UpperCase(Paths) + ' ;' );
117+ if P = 0 then
118+ begin
119+ P := Pos(' ;' + UpperCase(PathToRemove) + ' \;' , ' ;' + UpperCase(Paths) + ' ;' );
120+ end ;
121+
122+ if P > 0 then
123+ begin
124+ StringChangeEx(Paths, ' ;' + PathToRemove + ' ;' , ' ;' , True);
125+ StringChangeEx(Paths, PathToRemove + ' ;' , ' ' , True);
126+ StringChangeEx(Paths, ' ;' + PathToRemove, ' ' , True);
127+ RegWriteExpandStringValue(RootKey, SubKey, ValueName, Paths);
128+ end ;
129+ end ;
130+
131+ procedure CurUninstallStepChanged (CurUninstallStep: TUninstallStep);
132+ var
133+ AppPath: string;
134+ begin
135+ if CurUninstallStep = usUninstall then
136+ begin
137+ AppPath := ExpandConstant(' {app}' );
138+
139+ if IsAdminInstallMode then
140+ begin
141+ RemovePath(HKEY_LOCAL_MACHINE, ' SYSTEM\CurrentControlSet\Control\Session Manager\Environment' , ' Path' , AppPath);
142+ end
143+ else
144+ begin
145+ RemovePath(HKEY_CURRENT_USER, ' Environment' , ' Path' , AppPath);
146+ end ;
147+ end ;
148+ end ;
0 commit comments