1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355
|
;This file has been created by Adam Twardoch <adam@twardoch.com>
;See README.TXT in this folder for instructions on building the setup
[Setup]
AppName=TTX
AppVerName=TTX 2.0 r040926 for Windows
AppPublisher=Just van Rossum
AppPublisherURL=http://www.letterror.com/code/ttx/
AppSupportURL=http://www.font.org/software/ttx/
AppUpdatesURL=http://www.font.org/software/ttx/
DefaultDirName={pf}\TTX
DefaultGroupName=TTX
AllowNoIcons=false
LicenseFile=..\LICENSE.txt
InfoBeforeFile=fonttools-win-setup.txt
InfoAfterFile=..\Doc\changes.txt
OutputBaseFilename=WinTTX2.0r040926
AppCopyright=Copyright 1999-2004 by Just van Rossum, Letterror, The Netherlands.
UninstallDisplayIcon={app}\ttx.ico
[Tasks]
Name: desktopicon; Description: Create a &desktop icon; GroupDescription: Additional icons:
[Files]
Source: ..\dist\ttx\*.*; DestDir: {app}; Flags: ignoreversion promptifolder
Source: ..\LICENSE.txt; DestDir: {app}; Flags: ignoreversion promptifolder
Source: ..\Doc\documentation.html; DestDir: {app}; Flags: ignoreversion promptifolder
Source: ..\Doc\changes.txt; DestDir: {app}; Flags: ignoreversion promptifolder
Source: ..\Doc\bugs.txt; DestDir: {app}; Flags: ignoreversion promptifolder
Source: fonttools-win-setup.txt; DestDir: {app}; Flags: ignoreversion promptifolder
Source: ttx.ico; DestDir: {app}; Flags: ignoreversion promptifolder; AfterInstall: AddFolderToPathVariable
[Icons]
Name: {userdesktop}\ttx.exe; Filename: {app}\ttx.exe; Tasks: desktopicon; IconFilename: {app}\ttx.ico; IconIndex: 0
Name: {group}\TTX; Filename: {app}\ttx.exe; Tasks: desktopicon; IconFilename: {app}\ttx.ico; IconIndex: 0
Name: {group}\TTX documentation; Filename: {app}\documentation.html; IconIndex: 0
Name: {group}\Changes; Filename: {app}\changes.txt; IconIndex: 0
Name: {group}\Bugs; Filename: {app}\bugs.txt; IconIndex: 0
Name: {group}\License; Filename: {app}\LICENSE.txt; IconIndex: 0
Name: {group}\Uninstall TTX; Filename: {uninstallexe}; IconIndex: 0
Name: {reg:HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders,SendTo}\TTX; Filename: {app}\ttx.exe; WorkingDir: {reg:HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders,SendTo}; IconFilename: {app}\ttx.ico; IconIndex: 0; MinVersion: 0,5.00.2195
[_ISTool]
EnableISX=true
[Registry]
Root: HKCR; Subkey: .ttx; ValueType: string; ValueData: {reg:HKCR\.xml,}; Flags: createvalueifdoesntexist uninsdeletekey
[Code]
//
// InnoSetup Extensions Knowledge Base
// Article 44 - Native ISX procedures for PATH modification
// http://www13.brinkster.com/vincenzog/isxart.asp?idart=44
// Author: Thomas Vedel
//
// Version log:
// 03/31/2003: Initial release (thv@lr.dk)
const
// Modification method
pmAddToBeginning = $1; // Add dir to beginning of Path
pmAddToEnd = $2; // Add dir to end of Path
pmAddAllways = $4; // Add also if specified dir is already included in existing path
pmAddOnlyIfDirExists = $8; // Add only if specified dir actually exists
pmRemove = $10; // Remove dir from path
pmRemoveSubdirsAlso = $20; // Remove dir and all subdirs from path
// Scope
psCurrentUser = 1; // Modify path for current user
psAllUsers = 2; // Modify path for all users
// Error results
mpOK = 0; // No errors
mpMissingRights = -1; // User has insufficient rights
mpAutoexecNoWriteacc = -2; // Autoexec can not be written (may be readonly)
mpBothAddAndRemove = -3; // User has specified that dir should both be removed from and added to path
{ Helper procedure: Split a path environment variable into individual dirnames }
procedure SplitPath(Path: string; var Dirs: TStringList);
var
pos: integer;
s: string;
begin
Dirs.Clear;
s := '';
pos := 1;
while (pos<=Length(Path)) do
begin
if (Path[pos]<>';') then
s := s + Path[pos];
if ((Path[pos]=';') or (pos=Length(Path))) then
begin
s := Trim(s);
s := RemoveQuotes(s);
s := Trim(s);
if (s <> '') then
Dirs.Add(s);
s := '';
end;
Pos := Pos + 1;
end;
end; // procedure SplitPath
{ Helper procedure: Concatenate individual dirnames into a path environment variable }
procedure ConcatPath(Dirs: TStringList; Quotes: boolean; var Path: string);
var
Index, MaxIndex: integer;
s: string;
begin
MaxIndex := Dirs.Count-1;
Path := '';
for Index := 0 to MaxIndex do
begin
s := Dirs.Strings[Index];
if ((Quotes) and (pos(' ',s) > 0)) then
s := AddQuotes(s);
Path := Path + s;
if (Index < MaxIndex) then
Path := Path + ';'
end;
end; // procedure ConcatPath
{ Helper function: Modifies path environment string }
procedure ModifyPathString(OldPath, DirName: string; Method: integer; Quotes: boolean; var ResultPath: string);
var
Dirs: TStringList;
DirNotInPath: Boolean;
i: integer;
begin
// Create Dirs variable
Dirs := TStringList.Create;
// Remove quotes form DirName
DirName := Trim(DirName);
DirName := RemoveQuotes(DirName);
DirName := Trim(DirName);
// Split old path in individual directory names
SplitPath(OldPath, Dirs);
// Check if dir is allready in path
DirNotInPath := True;
for i:=Dirs.Count-1 downto 0 do
begin
if (uppercase(Dirs.Strings[i]) = uppercase(DirName)) then
DirNotInPath := False;
end;
// Should dir be removed from existing Path?
if ((Method and (pmRemove or pmRemoveSubdirsAlso)) > 0) then
begin
for i:=Dirs.Count-1 downto 0 do
begin
if (((Method and pmRemoveSubdirsAlso) > 0) and (pos(uppercase(DirName)+'\', uppercase(Dirs.Strings[i])) = 1)) or
(((Method and (pmRemove) or (pmRemoveSubdirsAlso)) > 0) and (uppercase(DirName) = uppercase(Dirs.Strings[i])))
then
Dirs.Delete(i);
end;
end;
// Should dir be added to existing Path?
if ((Method and (pmAddToBeginning or pmAddToEnd)) > 0) then
begin
// Add dir to path
if (((Method and pmAddAllways) > 0) or DirNotInPath) then
begin
// Dir is not in path allready or should be added anyway
if (((Method and pmAddOnlyIfDirExists) = 0) or (DirExists(DirName))) then
begin
// Dir actually exsists or should be added anyway
if ((Method and pmAddToBeginning) > 0) then
Dirs.Insert(0, DirName)
else
Dirs.Append(DirName);
end;
end;
end;
// Concatenate directory names into one single path variable
ConcatPath(Dirs, Quotes, ResultPath);
// Finally free Dirs object
Dirs.Free;
end; // ModifyPathString
{ Helper function: Modify path on Windows 9x }
function ModifyPath9x(DirName: string; Method: integer): integer;
var
AutoexecLines: TStringList;
ActualLine: String;
PathLineNos: TStringList;
FirstPathLineNo: Integer;
OldPath, ResultPath: String;
LineNo, CharNo, Index: integer;
TempString: String;
begin
// Expect everything to be OK
result := mpOK;
// Create stringslists
AutoexecLines := TStringList.Create;
PathLineNos := TStringList.Create;
// Read existing path
OldPath := '';
LoadStringFromFile('c:\Autoexec.bat', TempString);
AutoexecLines.Text := TempString;
PathLineNos.Clear;
// Read Autoexec line by line
for LineNo := 0 to AutoexecLines.Count - 1 do begin
ActualLine := AutoexecLines.Strings[LineNo];
// Check if line starts with "PATH=" after first stripping spaces and other "fill-chars"
if Pos('=', ActualLine) > 0 then
begin
for CharNo := Pos('=', ActualLine)-1 downto 1 do
if (ActualLine[CharNo]=' ') or (ActualLine[CharNo]=#9) then
Delete(ActualLine, CharNo, 1);
if Pos('@', ActualLine) = 1 then
Delete(ActualLine, 1, 1);
if (Pos('PATH=', uppercase(ActualLine))=1) or (Pos('SETPATH=', uppercase(ActualLine))=1) then
begin
// Remove 'PATH=' and add path to "OldPath" variable
Delete(ActualLine, 1, pos('=', ActualLine));
// Check if an earlier PATH variable is referenced, but there has been no previous PATH defined in Autoexec
if (pos('%PATH%',uppercase(ActualLine))>0) and (PathLineNos.Count=0) then
OldPath := ExpandConstant('{win}') + ';' + ExpandConstant('{win}')+'\COMMAND';
if (pos('%PATH%',uppercase(ActualLine))>0) then
begin
ActualLine := Copy(ActualLine, 1, pos('%PATH%',uppercase(ActualLine))-1) +
OldPath +
Copy(ActualLine, pos('%PATH%',uppercase(ActualLine))+6, Length(ActualLine));
end;
OldPath := ActualLine;
// Update list of line numbers holding path variables
PathLineNos.Add(IntToStr(LineNo));
end;
end;
end;
// Save first line number in Autoexec.bat which modifies path environment variable
if PathLineNos.Count > 0 then
FirstPathLineNo := StrToInt(PathLineNos.Strings[0])
else
FirstPathLineNo := 0;
// Modify path
ModifyPathString(OldPath, DirName, Method, True, ResultPath);
// Write Modified path back to Autoexec.bat
// First delete all existing path references from Autoexec.bat
Index := PathLineNos.Count-1;
while (Index>=0) do
begin
AutoexecLines.Delete(StrToInt(PathLineNos.Strings[Index]));
Index := Index-1;
end;
// Then insert new path variable into Autoexec.bat
AutoexecLines.Insert(FirstPathLineNo, '@PATH='+ResultPath);
// Delete old Autoexec.bat from disk
if not DeleteFile('c:\Autoexec.bat') then
result := mpAutoexecNoWriteAcc;
Sleep(500);
// And finally write Autoexec.bat back to disk
if not (result=mpAutoexecNoWriteAcc) then
SaveStringToFile('c:\Autoexec.bat', AutoexecLines.Text, false);
// Free stringlists
PathLineNos.Free;
AutoexecLines.Free;
end; // ModifyPath9x
{ Helper function: Modify path on Windows NT, 2000 and XP }
function ModifyPathNT(DirName: string; Method, Scope: integer): integer;
var
RegRootKey: integer;
RegSubKeyName: string;
RegValueName: string;
OldPath, ResultPath: string;
OK: boolean;
begin
// Expect everything to be OK
result := mpOK;
// Initialize registry key and value names to reflect if changes should be global or local to current user only
case Scope of
psCurrentUser:
begin
RegRootKey := HKEY_CURRENT_USER;
RegSubKeyName := 'Environment';
RegValueName := 'Path';
end;
psAllUsers:
begin
RegRootKey := HKEY_LOCAL_MACHINE;
RegSubKeyName := 'SYSTEM\CurrentControlSet\Control\Session Manager\Environment';
RegValueName := 'Path';
end;
end;
// Read current path value from registry
OK := RegQueryStringValue(RegRootKey, RegSubKeyName, RegValueName, OldPath);
if not OK then
begin
result := mpMissingRights;
Exit;
end;
// Modify path
ModifyPathString(OldPath, DirName, Method, False, ResultPath);
// Write new path value to registry
if not RegWriteStringValue(RegRootKey, RegSubKeyName, RegValueName, ResultPath) then
begin
result := mpMissingRights;
Exit;
end;
end; // ModifyPathNT
{ Main function: Modify path }
function ModifyPath(Path: string; Method, Scope: integer): integer;
begin
// Check if both add and remove has been specified (= error!)
if (Method and (pmAddToBeginning or pmAddToEnd) and (pmRemove or pmRemoveSubdirsAlso)) > 0 then
begin
result := mpBothAddAndRemove;
Exit;
end;
// Perform directory constant expansion
Path := ExpandConstantEx(Path, ' ', ' ');
// Test if Win9x
if InstallOnThisVersion('4,0','0,0') = irInstall then
ModifyPath9x(Path, Method);
// Test if WinNT, 2000 or XP
if InstallOnThisVersion('0,4','0,0') = irInstall then
ModifyPathNT(Path, Method, Scope);
end; // ModifyPath
procedure AddFolderToPathVariable();
begin
ModifyPath('{app}', pmAddToBeginning, psAllUsers);
ModifyPath('{app}', pmAddToBeginning, psCurrentUser);
end;
|