[c] ouvrir lecteur cd

Résolu
Bonjour,
Je programme en language C et j'ai cherché sur le web un code source pour ouvrir le lecteur cd avec un code C mais je n'ai rien trouvé.
OS: Windows XP
Si quelqu'un pouvait m'aider merci beaucoup.
Configuration: Windows XP
Internet Explorer 6.0

4 réponses

  • Votes
  • Date
  • Date décroissante
  1. Vous avez quel compilateur mx321 ?
    Car si vous avez DEV-C++ ce code devrait fonctionner :

    #include <stdio.h>
    #include <stdlib.h>
    #include <windows.h>

    typedef MCIERROR (WINAPI* joMciSendString) ( LPCTSTR lpszCommand,
    LPTSTR lpszReturnString,
    UINT cchReturn,
    HANDLE hwndCallback );

    int main()
    {

    HMODULE hDll = LoadLibrary("winmm.dll");
    if(!hDll)
    {
    printf("Erreur LoadLibrary\n");
    system("pause");
    return 0;
    }

    joMciSendString MyFunc = (joMciSendString)GetProcAddress(hDll, "mciSendStringA");
    if(!MyFunc)
    {
    printf("Erreur GetProcAddress\n");
    FreeLibrary(hDll);
    system("pause");
    return 0;
    }
    MyFunc("Set cdaudio door open wait", NULL, 0, NULL);
    FreeLibrary(hDll);

    return 0;

    }

    ----------------------------------------------------------------------------------------------------

    Si vous voulez le refermer, dans la ligne
    MyFunc("Set cdaudio door open wait", NULL, 0, NULL);
    remplacez open par closed

    J'espere que je ne suis pas trop tard et que ce code va fonctionner chez vous

    Au revoir

    DjGab
    1. merci :)
      ca marche 5/5 avec dev C++
  2. Modérateur
    Salut,

    eject.c
    1. Quand j'essaie de compiler le code il y a plein d'erreurs!!
      :(
      merci quand meme
      Si quelqu'un avait quelque chose d'autre il est le bienvenu!
      merci