如何控制多光驱(50分)

  • 主题发起人 主题发起人 zyxstar
  • 开始时间 开始时间
Z

zyxstar

Unregistered / Unconfirmed
GUEST, unregistred user!
如何象超霸一样在菜单里加入多光驱的支持?
 
这个问题很简单。给我EMAIL我发一个示例程序给你。
 
//打开光驱
mciSendString('Set cdaudiodo
or open wait', nil, 0, handle);

//关闭光驱
mciSendString('Set cdaudiodo
or closed wait', nil, 0, handle)
设置光盘的自动运行特征:
procedure TForm1.SetCDAutoRun(AAutoRun:Boolean);
const
do
AutoRun : array[Boolean] of Integer = (0,1);
var
Reg : TRegistry;
begin

try
{ create our registry object }
Reg := TRegistry.Create;
{ set our registry root key }
Reg.RootKey := HKEY_LOCAL_MACHINE;
{ verify that our CDROM class key exists }
if Reg.KeyExists('System/CurrentControlSet/Services/Class/CDROM') then

{ try to open our CDROM class key }
if Reg.OpenKey('System/CurrentControlSet/Services/Class/CDROM',FALSE) then

{ add AutoRun to our CDROM class key }
Reg.WriteBinaryData('AutoRun',DoAutoRun[AAutoRun],1);
finally
{ free our registry object }
Reg.Free;
end;

{ showmessage that the changes will happen on reboot }
ShowMessage('Your settings will take effect on the next reboot of Windows.');
end;

拦截消息WM_DEVICECHANGE即可!
//响应该消息
procedure Tform1.WMDEVICECHANGE(var msgx :Tmessage);
const
DBT_DEVICEARRIVAL=$8000;
DBT_DEVICEREMOVECOMPLETE=$8004;
begin

inherited;
case msgx.WParam of
DBT_DEVICEARRIVAL:Caption :='有了!';
DBT_DEVICEREMOVECOMPLETE:Caption :='取走了';
end;

end;

这些资料你瞧瞧有用不?
 
谢谢邹玉星和app2001,问题已解决。
 
后退
顶部