Pagina 1 di 2 1 2 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 13

Discussione: [C] Eject CD

  1. #1

    [C] Eject CD

    Come si fa' a far aprire lo sportellino del CD in C ???

    (Se e' possibile vorrei saperlo sia per Win che per Linux)
    PoWered by:
    Gentoo 1.5.3 - Kernel 2.6.7
    Debian Sid - Kernel 2.6.7 - Bash 3.0
    Slackware current - Kernel 2.6.7

  2. #2
    Per aprire il cassettino del lettore devi usare la api mciSendString in questo modo:

    codice:
    #include<stdio.h>
    #include<windows.h>
    int ris=0;
    char yo[100];
    main() {
    ris=mciSendString("set CDAudio door open",yo,100,0);
    }
    Ricordati però che devi dire al compilatore di importare anche la libreria winmm.lib pero non con l'include...

    Io con visual C faccio così.

    Vai su Project-->Settings..

    Nella Tab clicca su Link, e nella casella di testo vicino alla scritta Object/Libraries modules, inserisci in fondo winmm.lib

    A questo punto compila pure e il cassettino ti si apre...

    Se vuoi chiudere il cassettino basta che invece di "set CDAudio door open" gli metti "set CDAudio door closed"..

    Ciao ciao
    "Penso che nel mondo ci sia mercato per quattro o cinque computer"... Thomas Watson, presidente della IBM, 1943

  3. #3
    E funziona con tutti i lettori CD ???
    PoWered by:
    Gentoo 1.5.3 - Kernel 2.6.7
    Debian Sid - Kernel 2.6.7 - Bash 3.0
    Slackware current - Kernel 2.6.7

  4. #4
    Io Non ho nessuna libreria "winmm.lib"
    non me la trova... Neanche a fare "cerca" !!!!
    PoWered by:
    Gentoo 1.5.3 - Kernel 2.6.7
    Debian Sid - Kernel 2.6.7 - Bash 3.0
    Slackware current - Kernel 2.6.7

  5. #5
    dicci almeno che compilatore C utilizzi :quipy:

    con Dev C++ la libreria da includere è : libwinmm.a
    la trovi nella directory \LIB\ del compilatore.

    Per includerla al "Progetto": menù Progetto\Opzioni del progetto\Parametri\Linker\ (aggiungi libreria o oggetti)
    ...Terrible warlords, good warlords, and an english song

  6. #6
    Scusa Johnny hai ragione...
    cmq uso Dev C++

    Grazie Mille della Risposta..
    PoWered by:
    Gentoo 1.5.3 - Kernel 2.6.7
    Debian Sid - Kernel 2.6.7 - Bash 3.0
    Slackware current - Kernel 2.6.7

  7. #7
    Utente di HTML.it L'avatar di pdpmpd
    Registrato dal
    Jan 2003
    Messaggi
    448
    per linux:
    codice:
    #include <sys/ioctl.h>
    #include <sys/types.h>
    #include <sys/stat.h>
    #include <fcntl.h>
    #include <unistd.h>
    #include <linux/cdrom.h>
    
    main() {
    int fd=open("/dev/hdd",O_RDONLY | O_NONBLOCK);
    ioctl(fd,CDROMEJECT);
    close(fd);
    }
    sostituisci il device che vuoi usare
    Drug misuse is not a disease, it is a decision, like the decision to step out in front of a moving car. [...] In this particular life-style the motto is "be happy now because tomorrow you are dying", but the dying begins almost at once, and the happiness is a memory.

  8. #8
    Grazie...
    PoWered by:
    Gentoo 1.5.3 - Kernel 2.6.7
    Debian Sid - Kernel 2.6.7 - Bash 3.0
    Slackware current - Kernel 2.6.7

  9. #9
    Asso che storia...

    In teoria dovrebbe funzionare anche sotto linux?
    "Penso che nel mondo ci sia mercato per quattro o cinque computer"... Thomas Watson, presidente della IBM, 1943

  10. #10
    Utente di HTML.it L'avatar di pdpmpd
    Registrato dal
    Jan 2003
    Messaggi
    448
    Originariamente inviato da I'mtheleader
    Asso che storia...

    In teoria dovrebbe funzionare anche sotto linux?
    :master: quale?
    quello che ho postato io è per linux.
    Drug misuse is not a disease, it is a decision, like the decision to step out in front of a moving car. [...] In this particular life-style the motto is "be happy now because tomorrow you are dying", but the dying begins almost at once, and the happiness is a memory.

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.