PDA

View Full Version : Install Directory


dogyutz
19-04-2019, 21:06
hello all... how to script command of install directory. i want to always install destinationin my patition drive D.

Emorian
25-04-2019, 03:11
Work: Inno Setup Enhanced Unicode

Write The Setup Section:

AppName=My Program
AppVersion=5.0
DefaultDirName={code:DefDirWiz}
DefaultGroupName=My Program
UninstallDisplayIcon={app}\MyProg.exe
OutputDir=Output


Write the Code section:

const
// GetDriveType
DRIVE_UNKNOWN = 0; //UNKNOWN
DRIVE_NO_ROOT_DIR = 1; //Root path invalid
DRIVE_REMOVABLE = 2; //Removable
DRIVE_FIXED = 3; //Fixed
DRIVE_REMOTE = 4; //Network
DRIVE_CDROM = 5; //DVD-ROM and CD-ROM
DRIVE_RAMDISK = 6; //Ram disk
function GetLogicalDrives: DWord; external '[email protected] stdcall';
function GetDriveType(lpRootPathName: AnsiString): UInt; external '[email protected] stdcall';

Function NoSD: String;
var
x, bit, i: Integer;
tp: Cardinal;
sd: string;
Begin
sd := ExpandConstant('{sd}');
Result := ExpandConstant('{pf}\');
x := GetLogicalDrives;
if x <> 0 then begin
for i:= 1 to 64 do begin
bit := x and 1;
if bit = 1 then begin
tp := GetDriveType(PAnsiChar(Chr(64 + i) + ':'));
if tp = DRIVE_FIXED then begin
if Chr(64 + i) <> Copy(sd, 1, 1) then begin
Result := Chr(64 + i) + ':\Games\';
Break;
end;
end;
end;
x := x shr 1;
end;
end;
End;

Function _IsWin8: Boolean;
var
Version: TWindowsVersion;
Begin
GetWindowsVersionEx(Version);
if ((Version.Major = 6) and (Version.Minor > 1)) or (Version.Major > 6) then begin
Result := True; end
else begin
Result := False;
end;
End;

Function DefDirWiz(s: String): String;
Begin
if _IsWin8 then begin
Result := NoSD() + '{#GameDirName}'; end
else begin
Result := ExpandConstant('{pf}\') + '{#GameDirName}';
end;
End;

heihuanlanhun
19-07-2019, 21:29
25090
when I use the chinese Windows 10 ,it is wrong

what should I do?