1.我想做个自动读取驱动器盘符,该如何实现,请各位帮帮!

解决方案 »

  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