请问各位高手,如何获得光盘的驱动盘符?(100分)

  • 主题发起人 主题发起人 lsa_78
  • 开始时间 开始时间
L

lsa_78

Unregistered / Unconfirmed
GUEST, unregistred user!
请问各位高手,如何获得光盘的驱动盘符?
 
来自:beta, 时间:2002-03-24 14:06:00, ID:999696<br><br>function GetCDRom: string; <br>var <br>c: Char; <br>Drive: string; <br>DriveType: UINT; <br>DriveSize: Int64; <br>begin <br>for c := 'A' to 'Z' do <br>begin <br>DriveSize := DiskSize(Ord(c) - Ord('A') + 1); <br>if DriveSize &gt; 0 then <br>begin <br>Drive := c + ':'; <br>DriveType := GetDriveType(PChar(Drive)); <br>if DriveType = DRIVE_CDROM then <br>begin <br>Result := Drive; <br>Exit; <br>end; <br>end <br>else <br>if c &gt;= 'C' then <br>Exit; <br>end; <br>end;<br>&nbsp;<br>&nbsp;<br>来自:kingdeezj, 时间:2002-03-24 14:51:00, ID:999733 <br><br>procedure TForm1.Button1Click(Sender: TObject); <br><br>var <br>drive:char; <br>begin <br>for drive:='a' to 'z' do <br>begin <br>Case GetDriveType(pchar(Drive+':/')) of <br>2: Label1.Caption :='软盘驱动器'; <br>3: Label1.Caption := '硬盘驱动器'; <br>4: Label1.Caption := '网络驱动器'; <br>5: Label1.Caption := 'CD-ROM驱动器'; <br>6: Label1.Caption := '虚拟驱动器'; <br>Else Label1.Caption := '驱动器无效'; <br>end; <br>if GetDriveType(pchar(Drive+':/'))in[2,3,4,5,6] then <br>ComboBox1.Items.Add(pchar(drive+':/ ')+label1.Caption); <br>x:=x+1; <br>if x&gt;y then begin <br>showmessage(' Done !'); <br>exit; <br>end; <br>end; <br>end;
 
写了一个稍为简单的<br>var<br>&nbsp; i: Integer;<br>&nbsp; Str: string;<br>begin<br>&nbsp; for i := Ord('A') to Ord('Z') do<br>&nbsp; begin<br>&nbsp; &nbsp; Str := Char(i)+':';<br>&nbsp; &nbsp; if GetDriveType(PChar(Str)) = DRIVE_CDROM then<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; Str := 'The CDROM driver is '+PChar(Str);<br>&nbsp; &nbsp; &nbsp; MessageBox(Handle, PChar(Str), 'Information', mb_OK);<br>&nbsp; &nbsp; &nbsp; Exit;<br>&nbsp; &nbsp; end;<br>&nbsp; end;<br>&nbsp; MessageBox(Handle,'Not Found',0,0);<br>end;
 
function getdrives:integer;<br>var<br>i,c:integer;<br>begin<br>result:=0;<br>c:=0;<br>for i:=0 to 25 do<br>begin<br>if getdrivetype(pchar(chr(i+65)+':/'))=DRIVE_CDROM then<br>begin<br>cdroom[c]:=chr(i+65);<br>c:=c+1;<br>end;<br>end;<br>result:=c-1;<br>end;
 
后退
顶部