请问如何取得计算机内所有盘符?
最好可以知道某某是软盘,某某是移动盘,某某是硬盘(又分主盘和从盘)
谢谢

解决方案 »

  1.   

    Unit
    Windows.PasSyntax
    GetDriveType(
    lpRootPathName: PChar {a pointer to the root path string}
    ): UINT;  {returns a value based on the drive type}Description
    GetDriveType is used to determine the type of drive being accessed, and will indicate fixed, removable, or remote (network) drives.Parameters
    lpRootPathName: A null terminated string containing the root directory of the drive to be queried. If this parameter is NIL, the function uses the root of the current directory.Return Value
    If the function is successful, it returns one value, otherwise it returns DRIVE_UNKNOWN.The Tomes of Delphi 3: Win32 Core API Help File by Larry Diehlprocedure TForm1.DriveComboBox1Change(Sender: TObject);
    var
      DrivePath: array[0..3] of char;     // holds the root directory to query
    begin
      {assemble the name of the root path of the drive to query}
      StrPCopy(DrivePath, DriveComboBox1.Drive);
      StrCat(DrivePath, ':\');  {retrieve the drive type and display it}
      case GetDriveType(DrivePath) of
        DRIVE_UNKNOWN:     Panel1.Caption := 'No Type Information';    DRIVE_NO_ROOT_DIR: Label1.Caption := 'Root Directory does not exist';
        DRIVE_REMOVABLE:   Panel1.Caption := 'Removable';
        DRIVE_FIXED:       Panel1.Caption := 'Fixed';
        DRIVE_REMOTE:      Panel1.Caption := 'Remote';
        DRIVE_CDROM:       Panel1.Caption := 'CDROM';
        DRIVE_RAMDISK:     Panel1.Caption := 'RamDisk';
      end;
    end;The Tomes of Delphi 3: Win32 Core API Help File by Larry Diehl