CDROM Control(30分)

  • 主题发起人 主题发起人 varphone
  • 开始时间 开始时间
V

varphone

Unregistered / Unconfirmed
GUEST, unregistred user!
How to eject or closedo
or of the cdrom(not the firt cdrom,i have three cdrom);
 
分数太少,。。。
 
I can add 20 to you,tell me how todo
ne!
 
---- 这可以利用MCI(Media Control Interface)函数中的mciSendString()来实现,MCI可以简单地看作是一组用来控制多媒体设备的函数,这些函数包含在动态连接库MMSYSTEM.DLL中,该库文件位于Windows3.x、Windows 95/98或Windows NT的SYSTEM子目录中。

打开CDROM门:
mciSendString('Set cdaudiodo
or
open wait', nil, 0, handle);

关闭CDROM门:
mciSendString('Set cdaudiodo
or
closed wait', nil, 0, handle);


---- 为了使用这个函数,记住在单元的USES子句中,一定要包含MMSystem单元。
 
Not this,your code just can control the first cdrom,this i know.
but,now i wnat to eject the 2th of 3th cdrom,your code can'tdo
it!
 

Function OpenCD(Drive : Char) : Boolean;
Var
Res : MciError;
OpenParm: TMCI_Open_Parms;
Flags : DWord;
S : String;
DeviceID : Word;
begin

Result:=false;
S:=Drive+':';
Flags:=mci_Open_Type or mci_Open_Element;
With OpenParmdo

begin

dwCallback := 0;
lpstrDeviceType := 'CDAudio';
lpstrElementName := PChar(S);
end;

Res := mciSendCommand(0, mci_Open, Flags, Longint(@OpenParm));
IF Res<>0 then

exit;
DeviceID:=OpenParm.wDeviceID;
try
Res:=mciSendCommand(DeviceID, MCI_SET, MCI_SET_DOOR_OPEN, 0);
IF Res=0 then

exit;
Result:=True;
finally
mciSendCommand(DeviceID, mci_Close, Flags, Longint(@OpenParm));
end;

end;




----------------------FUNCTION TO CLOSE THE CD

Function CloseCD(Drive : Char) : Boolean;
Var
Res : MciError;
OpenParm: TMCI_Open_Parms;
Flags : DWord;
S : String;
DeviceID : Word;
begin

Result:=false;
S:=Drive+':';
Flags:=mci_Open_Type or mci_Open_Element;
With OpenParmdo

begin

dwCallback := 0;
lpstrDeviceType := 'CDAudio';
lpstrElementName := PChar(S);
end;

Res := mciSendCommand(0, mci_Open, Flags, Longint(@OpenParm));
IF Res<>0 then

exit;
DeviceID:=OpenParm.wDeviceID;
try
Res:=mciSendCommand(DeviceID, MCI_SET, MCI_SET_DOOR_CLOSED, 0);
IF Res=0 then

exit;
Result:=True;
finally
mciSendCommand(DeviceID, mci_Close, Flags, Longint(@OpenParm));
end;

end;
 
分太少了,真不想给你,看在大家同道,就吃点亏吧[:D]
 
DragonPC???:
next time,i'll give you more score,thank you!
 

Similar threads

A
回复
0
查看
932
Andreas Hausladen
A
A
回复
0
查看
981
Andreas Hausladen
A
A
回复
0
查看
607
Andreas Hausladen
A
A
回复
0
查看
805
Andreas Hausladen
A
后退
顶部