Einzelnen Beitrag anzeigen

n00b2key

Registriert seit: 3. Jan 2003
11 Beiträge
 
#3

Re: wieso werden PChar Werte im dyn. Array gelöscht?

  Alt 6. Sep 2004, 00:06
Code:
procedure TForm1.List_Drives;
var
 r: LongWord;
 Drives: array[0..128] of char;
 pDrive: PChar;
begin
 SetLength(aDrives,0);
 r := GetLogicalDriveStrings(SizeOf(Drives), Drives);
 if r = 0 then Exit;
 if r > SizeOf(Drives) then
   raise Exception.Create(SysErrorMessage(ERROR_OUTOFMEMORY));
 pDrive := Drives;
 while pDrive^ <> #0 do
 begin
   SetLength(aDrives, Length(aDrives)+1);
   if GetDriveType(pDrive) = DRIVE_UNKNOWN then
   begin
     aDrives[High(aDrives)].Drive := pDrive;
     aDrives[High(aDrives)].Device := DRIVE_UNKNOWN;
   end;
   if GetDriveType(pDrive) = DRIVE_NO_ROOT_DIR then
   begin
     aDrives[High(aDrives)].Drive := pDrive;
     aDrives[High(aDrives)].Device := DRIVE_NO_ROOT_DIR;
   end;
   if GetDriveType(pDrive) = DRIVE_REMOVABLE then
   begin
     aDrives[High(aDrives)].Drive := pDrive;
     aDrives[High(aDrives)].Device := DRIVE_REMOVABLE;
   end;
   if GetDriveType(pDrive) = DRIVE_FIXED then
   begin
     aDrives[High(aDrives)].Drive := pDrive;
     aDrives[High(aDrives)].Device := DRIVE_FIXED;
   end;
   if GetDriveType(pDrive) = DRIVE_REMOTE then
   begin
     aDrives[High(aDrives)].Drive := pDrive;
     aDrives[High(aDrives)].Device := DRIVE_REMOTE;
   end;
   if GetDriveType(pDrive) = DRIVE_CDROM then
   begin
     aDrives[High(aDrives)].Drive := pDrive;
     aDrives[High(aDrives)].Device := DRIVE_CDROM;
   end;
   if GetDriveType(pDrive) = DRIVE_RAMDISK then
   begin
     aDrives[High(aDrives)].Drive := pDrive;
     aDrives[High(aDrives)].Device := DRIVE_RAMDISK;
   end;

   Inc(pDrive, 4);
 end;
 SetLength(DriveBtns, Length(aDrives));
end;
Ich bin n00b und das ist auch gut so!
  Mit Zitat antworten Zitat