FileForums

FileForums (https://fileforums.com/index.php)
-   Conversion Tutorials (https://fileforums.com/forumdisplay.php?f=55)
-   -   Inno setup - NoSD Code (plz help me) (https://fileforums.com/showthread.php?t=103466)

sakila(playboy) 25-04-2020 07:33

Inno setup - NoSD Code (plz help me)
 
Can anyone tell me what's wrong this?


const
DRIVE_UNKNOWN = 0;
DRIVE_NO_ROOT_DIR = 1;
DRIVE_REMOVABLE = 2;
DRIVE_FIXED = 3;
DRIVE_REMOTE = 4;
DRIVE_CDROM = 5;
DRIVE_RAMDISK = 6;
SHCNE_ASSOCCHANGED = $08000000;
SHCNF_IDLIST = $00000000;

function GetLogicalDrives: DWord;
external '[email protected] stdcall';
function GetDriveTypeA(lpRootPathName: AnsiString): UInt;
external '[email protected] stdcall';

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

Cesar82 25-04-2020 09:08

The code is working correctly.
It returns the first drive unit found that is fixed (HD/SSD) and is not the system drive.

Emorian 25-05-2020 17:15

Quote:

Originally Posted by sakila(playboy) (Post 485471)
Can anyone tell me what's wrong this?


Work:
Red = you add
Green = delete
Code:

  var
  x, bit, i: Integer;
  tp: Cardinal;
  sd: string;
  Begin
  sd := ExpandConstant('{sd}');
  Result := ExpandConstant('{pf}\');
  x := GetLogicalDrives;
  If x <> 0 Then
    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
        If Chr(64 + i) <> Copy(sd, 1, 1) Then
          Begin
          Result := Chr(64 + i) + ':\Games\';
          Break;
          End;
      End;
      x := x shr 1;
    End;
  End;
End;



All times are GMT -7. The time now is 12:29.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
FileForums @ https://fileforums.com