View Single Post
  #2  
Old 25-04-2019, 03:11
Emorian Emorian is offline
Registered User
 
Join Date: Oct 2011
Location: Hungary
Posts: 26
Thanks: 14
Thanked 4 Times in 4 Posts
Emorian is on a distinguished road
Work: Inno Setup Enhanced Unicode

Write The Setup Section:
Code:
AppName=My Program
AppVersion=5.0
DefaultDirName={code:DefDirWiz}
DefaultGroupName=My Program
UninstallDisplayIcon={app}\MyProg.exe
OutputDir=Output
Write the Code section:
Code:
 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;
Reply With Quote