OUVRIR/FERMER UN LECTEUR CD SIMPLEMENT

cs_Gysmo Messages postés 209 Date d'inscription lundi 11 février 2002 Statut Membre Dernière intervention 13 décembre 2002 - 20 août 2002 à 15:59
c3rb3r3 Messages postés 38 Date d'inscription mardi 17 décembre 2002 Statut Membre Dernière intervention 25 janvier 2006 - 27 juil. 2005 à 00:55
Cette discussion concerne un article du site. Pour la consulter dans son contexte d'origine, cliquez sur le lien ci-dessous.

https://codes-sources.commentcamarche.net/source/11793-ouvrir-fermer-un-lecteur-cd-simplement

c3rb3r3 Messages postés 38 Date d'inscription mardi 17 décembre 2002 Statut Membre Dernière intervention 25 janvier 2006
27 juil. 2005 à 00:55
Ah enfin ...
Bien joué Pag pour avoir trouvé la source de l'unit DriveTools, je la cherchais depuis un moment.

Vous ferez attention si vous l'utilisez, il faut remplacer certains caractères dûs au navigateur.

Pour exemple:
IF Res<>0 Then exit;

En clair, c'est Si Res supérieur à 0. C'est sûrement pour celà que slachz n'a pas réussi à le faire fonctionner.
George Dujardin Messages postés 1 Date d'inscription dimanche 23 janvier 2005 Statut Membre Dernière intervention 14 février 2005
14 févr. 2005 à 19:26
Génial.
J'ai essayé les 2 autres sources mais aucune ne fonctionne sous WXP ou W 98. Par contre celle-ci fonctionne bien.
slachz Messages postés 109 Date d'inscription lundi 21 avril 2003 Statut Membre Dernière intervention 1 janvier 2006
16 juil. 2004 à 00:45
cs_Gysmo Messages postés 209 Date d'inscription lundi 11 février 2002 Statut Membre Dernière intervention 13 décembre 2002
20 août 2002 à 15:59
Super génial!!!

Un grand merci à toi Pag! ;)

Babaille.
cs_Pag Messages postés 5 Date d'inscription mardi 20 août 2002 Statut Membre Dernière intervention 18 avril 2007
20 août 2002 à 07:47
J'ai trouver la source: ---->


// ____ _ ______ __
// / __ \_____(_) _____/_ __/___ ____ / /____
// / / / / ___/ / | / / _ / / / __ / __ / / ___/
// / /_/ / / / /| |/ / __/ / / /_/ / /_/ / (__ )
// /_____/_/ /_/ |___/\___/_/ \____/\____/_/____/
//
(*******************************************************************************
* DriveTools 1.0 *
* *
* (c) 1999 Jan Peter Stotz *
* *
********************************************************************************
* *
* If you find bugs, has ideas for missing featurs, feel free to contact me *
* jpstotz@gmx.de *
* *
********************************************************************************
* Date last modified: May 22, 1999 *
*******************************************************************************)

unit DriveTools;

interface

uses
Windows, SysUtils, MMSystem;

function CloseCD(Drive : Char) : Boolean;
function OpenCD(Drive : Char) : Boolean;

implementation

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;

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 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;


end.
Rejoignez-nous