如何禁用光驱设备???(100分)

  • 主题发起人 主题发起人 nachuan
  • 开始时间 开始时间
N

nachuan

Unregistered / Unconfirmed
GUEST, unregistred user!
用什么办法,调用什么函数,可以实现让windows系统的光驱停用,效果和在设备管理器中让某个设备停用一样,并且可以恢复。有多个光驱可以让多个光驱都停用。<br>找了好多资料都是让光驱打开或关闭的,或者判断是否正常等,没有发现如何禁用(停用)某个设备的API,也不知道和注册表有没有关系,<br>哪位大虾知道请指点迷经!!!<br>
 
procedure ShieldCDs;<br>&nbsp; function IsCDROM(DriveChar: Char): Boolean;<br>&nbsp; begin<br>&nbsp; &nbsp; Result := GetDriveType(PChar(DriveChar + ':/')) = DRIVE_CDROM;<br>&nbsp; end;<br>const<br>&nbsp; _PATH = '/Software/Microsoft/Windows/CurrentVersion/Policies/Explorer';<br>var<br>&nbsp; I, T: Integer;<br>&nbsp; Buffer, Mask: DWORD;<br>&nbsp; R: TRegistry;<br>begin<br>&nbsp; Mask := 0;<br>&nbsp; for I := 0 to 25 do<br>&nbsp; &nbsp; if IsCDROM(Char(I + Ord('A'))) then Mask := Mask + 1 shl I;<br>&nbsp; R := TRegistry.Create;<br>&nbsp; R.Rootkey := HKEY_CURRENT_USER;<br>&nbsp; R.CreateKey(_PATH);<br>&nbsp; R.OpenKey(_PATH, False);<br>&nbsp; if R.ReadBinaryData('NoDrives', Buffer, SizeOf(Buffer)) = 0 then Buffer := 0;<br>&nbsp; Buffer := Buffer and not Mask or Mask; // 为了不破坏对其它驱动器的设置。<br>&nbsp; R.WriteBinaryData('NoDrives', Buffer, SizeOf(Buffer));<br>&nbsp; R.Free;<br>end;<br><br>
 
后退
顶部