Einzelnen Beitrag anzeigen

omata

Registriert seit: 26. Aug 2004
Ort: Nebel auf Amrum
3.154 Beiträge
 
Delphi 7 Enterprise
 
#2

AW: Get Drive Letter

  Alt 23. Okt 2011, 22:17
Delphi-Quellcode:
function GetDriveLetter(DriveIdx:byte):string;
var
  vDrivesSize: Cardinal;
  vDrives : array[0..128] of Char;
  vDrive : PChar;
  Drive:string;
  Index:byte;
begin
  if DriveIdx = 0 then
    GetDir(DriveIdx, Drive)
  else begin
    vDrivesSize := GetLogicalDriveStrings(SizeOf(vDrives), vDrives);
    if vDrivesSize <> 0 then begin
      Index:=0;
      vDrive := vDrives;
      while (vDrive^ <> #0) and (Index < DriveIdx) do begin
        Drive:=StrPas(vDrive);
        Inc(vDrive, SizeOf(vDrive));
        inc(Index);
      end;
    end;
  end;
  Result:=copy(Drive, 1, 1);
end;
  Mit Zitat antworten Zitat