rt

解决方案 »

  1.   

    1 使用PSAPI 
    2 应用 WMI
      

  2.   

    最后一个不一定就是光驱,计算机上不一定有光驱,也不一定就只有一个光驱~~~从'A'-'Z'遍历一遍~~~用API GetDriveType判断驱动器类型返回值含义:0 The drive type cannot be determined.
    1 The root directory does not exist.
    DRIVE_REMOVABLE The drive can be removed from the drive.
    DRIVE_FIXED The disk cannot be removed from the drive.
    DRIVE_REMOTE The drive is a remote (network) drive.
    DRIVE_CDROM The drive is a CD-ROM drive.
    DRIVE_RAMDISK The drive is a RAM disk.
      

  3.   

    DriveComboBox1.Items.Strings[DriveComboBox1.Items.Count-1]
    如果有映射的网络驱动器就不行了
      

  4.   

    补充:设置DriveComboBox1不可见
      

  5.   

    for t := 0 to 25 do
    begin
      DriveRoot := Chr(t + Ord('a')) + ':\';
      if GetDriveType(PChar(DriveRoot)) = DRIVE_CDROM then
        //...
    end;因为A:、B:肯定不是光驱,只判断光驱可从C:开始,2-25~~~
      

  6.   

    function CDROM:string;
    var curDrive:char;
    begin
      for curDrive='Z' downto 'D'
       if GetDriveType(PChar(curDrive+':\'))=DRIVE_CDROM then
       begin
         Result:=curDrive+':\';
         exit;
       end;
       raise exception.create('No cdrom detected.');
    end;