Advertisement
miguelhosttimer

drives existentes

May 16th, 2024
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 1.26 KB | None | 0 0
  1.   unit Unit1;
  2.  
  3. interface
  4.  
  5. uses
  6.   Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  7.   Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;
  8.  
  9. type
  10.   TForm1 = class(TForm)
  11.     Button1: TButton;
  12.     ListBox1: TListBox;
  13.     procedure Button1Click(Sender: TObject);
  14.   private
  15.     { Private declarations }
  16.   public
  17.     { Public declarations }
  18.   end;
  19.  
  20. var
  21.   Form1: TForm1;
  22.  
  23. implementation
  24.  
  25. {$R *.dfm}
  26.  
  27. procedure TForm1.Button1Click(Sender: TObject);
  28. var
  29.   DriveNum: Integer;
  30.   DriveChar: Char;
  31.   DriveBits: set of 0..25;
  32.   DriveType: Integer;
  33. begin
  34.   Integer(DriveBits) := GetLogicalDrives;
  35.   for DriveNum := 0 to 25 do
  36.   begin
  37.     if not (DriveNum in DriveBits) then
  38.     begin
  39.       Continue;
  40.     end;
  41.     DriveChar := UpCase(Char(DriveNum + Ord('a')));
  42.     DriveType := GetDriveType(PChar(DriveChar +':\'));
  43.     case DriveType of
  44.       DRIVE_REMOVABLE: ListBox1.Items.Add(DriveChar + ': Disco Flexível');
  45.       DRIVE_FIXED: ListBox1.Items.Add(DriveChar + ': Disco Fixo');
  46.       DRIVE_REMOTE: ListBox1.Items.Add(DriveChar + ': Network Volume');
  47.       DRIVE_CDROM: ListBox1.Items.Add(DriveChar + ': CD-ROM');
  48.       DRIVE_RAMDISK: ListBox1.Items.Add(DriveChar + ': RAM');
  49.     end;
  50.   end;
  51. end;
  52.  
  53. end.
  54.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement