unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, MMSystem, StdCtrls;type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
procedure Button1Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
begin
// mciSendStringA('set CDAudio door open', nil, 0, 0);
mcisendstring('set CDAudio door open wait',nil,0,handle);//开光驱
end;procedure TForm1.Button3Click(Sender: TObject);
begin
close;
end;procedure TForm1.Button2Click(Sender: TObject);
begin
//mciSendStringA('set CDAudio door closed', nil, 0, 0);
mcisendstring('set CDAudio door closed wait',nil,0,handle);//关光驱
end;end.上面的代码,只能打开,但不能关闭,求解?
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, MMSystem, StdCtrls;type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
procedure Button1Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
begin
// mciSendStringA('set CDAudio door open', nil, 0, 0);
mcisendstring('set CDAudio door open wait',nil,0,handle);//开光驱
end;procedure TForm1.Button3Click(Sender: TObject);
begin
close;
end;procedure TForm1.Button2Click(Sender: TObject);
begin
//mciSendStringA('set CDAudio door closed', nil, 0, 0);
mcisendstring('set CDAudio door closed wait',nil,0,handle);//关光驱
end;end.上面的代码,只能打开,但不能关闭,求解?
解决方案 »
- 下山的速度
- 我在动态链链接库中放置的TDBEdit和TDBGrid,程序执行,调用时都无法编辑,请问是怎么回事?
- tts怎样朗读中文?
- 为什么我的控件提示安装成功了,可是在控件栏上却没有了???
- 高分急问QuickREp问题??
- 有关过滤的问题--急
- 我想知道怎么样才算是个程序员?
- 如何在用QReport控件打印时,设置打印页面大小。
- 我有一个系统将正式应用,大家觉得用盗版WIN2000SERVER+SQLSERVER2000企业版保险吗?
- 小新、focus、taxi、忍者☆☆☆☆☆Dblistlistbox如何显示数据库中的某一个字段?
- 这段程序总提示错误:键列信息不足或错误,影响到多行
- 请问哪有OutlookBar控件下载???
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 OpenParm do
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 CloseCDROM(Drive:pChar):Boolean; // 关闭CDROM
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 OpenParm do
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;
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, MMSystem;type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Edit1: TEdit;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}function OpenCDROM(Drive:pChar):Boolean; // 打开CDROM
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 OpenParm do
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 CloseCDROM(Drive:pChar):Boolean; // 关闭CDROM
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 OpenParm do
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;
procedure TForm1.Button1Click(Sender: TObject);
begin
OpenCDROM('F'); // F 是光驱盘符
end;procedure TForm1.Button2Click(Sender: TObject);
begin
CloseCDROM('F');
end;end.
begin
//打开CDROM门:
mciSendString('Set CdAudio Door Open', nil, 0, 0);
end;procedure TForm1.Button2Click(Sender: TObject);
begin
//关闭CDROM门:
mciSendString('Set CdAudio Door Closed', nil, 0, 0);
end;
楼上的代码测试成功,应该没问题啊
上传了我光盘上的一个源码
不过没测试,家长为了让我专心准备高考把delphi卸了……