如何获得所有光驱的名称? ( 积分: 100 )

  • 主题发起人 主题发起人 kasd
  • 开始时间 开始时间
K

kasd

Unregistered / Unconfirmed
GUEST, unregistred user!
RT<br>谢谢!
 
RT<br>谢谢!
 
自己把帖子提前
 
取当前可用驱动器<br><br>返回值为一个字符串,形如'ABCD'<br>function myGetLogicalDrives : String;<br>var<br> &nbsp; drives &nbsp;: set of 0..25;<br> &nbsp; drive &nbsp; : integer;<br>begin<br> &nbsp; Result := '';<br> &nbsp; DWORD( drives ) := Windows.GetLogicalDrives;<br> &nbsp; for drive := 0 to 25 do<br> &nbsp; &nbsp; &nbsp;if drive in drives then<br> &nbsp; &nbsp; &nbsp; &nbsp; Result := Result + Chr( drive + Ord( 'A' ));<br>end;<br><br>然后判断驱动器的类型<br>procedure TForm1.Button1Click(Sender: TObject); <br>var <br> &nbsp;typ: Integer; <br> &nbsp;s: &nbsp; string; <br>begin <br> &nbsp;s &nbsp; := 'C:/'; <br> &nbsp;typ := GetDriveType(PChar(s)); <br> &nbsp;if Typ &lt;&gt; 0 then case typ of <br> &nbsp; &nbsp; &nbsp;DRIVE_REMOVABLE: <br> &nbsp; &nbsp; &nbsp; &nbsp;begin <br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ShowMessage('Drive Removable / Diskette'); <br> &nbsp; &nbsp; &nbsp; &nbsp;end; <br> &nbsp; &nbsp; &nbsp;DRIVE_FIXED: <br> &nbsp; &nbsp; &nbsp; &nbsp;begin <br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ShowMessage('Drive fixed / Festplatte'); <br> &nbsp; &nbsp; &nbsp; &nbsp;end; <br> &nbsp; &nbsp; &nbsp;DRIVE_CDROM: <br> &nbsp; &nbsp; &nbsp; &nbsp;begin <br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ShowMessage('CD ROM Drive'); <br> &nbsp; &nbsp; &nbsp; &nbsp;end; <br> &nbsp; &nbsp; &nbsp;DRIVE_RAMDISK: <br> &nbsp; &nbsp; &nbsp; &nbsp;begin <br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ShowMessage('RAM Drive'); <br> &nbsp; &nbsp; &nbsp; &nbsp;end; <br> &nbsp; &nbsp; &nbsp;DRIVE_REMOTE: <br> &nbsp; &nbsp; &nbsp; &nbsp;begin <br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ShowMessage('Remote Drive / Netzlaufwerk'); <br> &nbsp; &nbsp; &nbsp; &nbsp;end; <br> &nbsp; &nbsp;end; <br>end;
 
转载<br>http://www.delphibbs.com/delphibbs/dispq.asp?lid=1623163
 
楼上的没有理解我的意思,我要的不是盘符,是光驱的名称<br>比如:ATAPI-CDROM-DRIVE-52MAX
 
最简单方法是:在注册表中搜索硬件设备<br>HKEY_LOCAL_MACHINE/HARDWARE/DEVICEMAP下应该有
 
搞定了<br>确实在注册表里<br>谢谢大家
 
后退
顶部