下面代码中'e:\'表示光驱所在盘符。
procedure TForm1.Button2Click(Sender: TObject);
var
  i:dword;
  buf:array[0..MAX_PATH] of char;
  pd:DWORD;
begin
  pd:=0;
  GetVolumeInformation('e:\',buf,i,@pd,i,i,buf,i);
  caption:=inttohex(pd,8);
  if pd=0 then showmessage('Not Ready');
end;

解决方案 »

  1.   

    procedure 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;
      

  2.   

    检测光驱
    var
      DriveType:integer;
      i:integer;
      c:string;
    begin
      for i:=65 to 90 do begin
        c:=chr(i)+':\';
        DriveType:=GetDirveType(Pchar(c));//得出驱动器的类型
        if DriveType=DRIVE_CDROM then
           //做你要做的事;
      end;
    end;//成功了别忘了给分啊!!哈。。
      

  3.   

    用 GetDriveType 来得到光驱盘符;
    用 GetVolumeInformation()得到光驱的信息,