Fórum Como abro a gaveta do cd escolhendo a unidade desejada? #151519
03/04/2003
0
Ex: Tenho um ´listbox´ com letras de ´d´ até ´z´. Se eu escolher ´f´ o cd a unidade ´f:´ se abre. Alguém pode me ajudar?
Pitbinho
Curtir tópico
+ 0
Responder
Posts
03/04/2003
Anonymous
Vc pode usar um if para verificar se o listbox esta na letra F, se tiver vc faz o seguinte
Inclua na seção uses: MMSystem
{ Para abrir }
mciSendString(´Set cdaudio door open wait´, nil, 0, handle);
{ Para fechar }
mciSendString(´Set cdaudio door closed wait´, nil, 0, handle);
acho q isso te ajudará, agora é com vc ... falow
Fernando Souza
Votorantim-SP
Inclua na seção uses: MMSystem
{ Para abrir }
mciSendString(´Set cdaudio door open wait´, nil, 0, handle);
{ Para fechar }
mciSendString(´Set cdaudio door closed wait´, nil, 0, handle);
acho q isso te ajudará, agora é com vc ... falow
Fernando Souza
Votorantim-SP
Responder
Gostei + 0
03/04/2003
Rafaela
Tenta o seguinte:
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 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;
No ovento onclick do listbox coloca:
If Listbox1.Items[Listbox1.ItemIndex] = ´f´ then
OpenCd;
Espero ter ajudado
Rafaela
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 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;
No ovento onclick do listbox coloca:
If Listbox1.Items[Listbox1.ItemIndex] = ´f´ then
OpenCd;
Espero ter ajudado
Rafaela
Responder
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)