3
I want to create an algorithm in C to open and close the CD-ROM drive, I took a look at some tutorials but they ended up not working. I would like to know which libraries you should use.
3
I want to create an algorithm in C to open and close the CD-ROM drive, I took a look at some tutorials but they ended up not working. I would like to know which libraries you should use.
Browser other questions tagged c windows winapi
You are not signed in. Login or sign up in order to post.
Depends on OS. And is easier in the system shell
– Jefferson Quesado
@Jeffersonquesado Windows 7. I know that in Linux the code is very short. But in Windows, by the tutorials I could not. So I thought I’d create one myself, but I wanted to know which libraries to use.
– Algeu Junior
@Marinero: Well, I found the question very relevant, with the correct TAGS, and could add a lot to the Sopt community: https://pastebin.com/qZW7aEkP
– Lacobus
Maybe I’m taking a risk, but I voted to reopen giving Lacobus the opportunity to answer (I’m not going to say it works, because it’s not something I dominate). ps: @lacobus I don’t dominate C as much as you do, but I believe that
true
andfalse
need adefine
, or Enum or even<stdbool.h>
, of course you may have assumed that this is something intuitive for the author, but sometimes he may beginner.– Guilherme Nascimento
@Guilhermenascimento: You’re right. The type
bool
, and the constantstrue
andfalse
are unique to theC++
and are not part of the standardC
.– Lacobus
@Lacobus already voted to reopen, 3 votes are missing, now just wait. PS: O
stdbool.h
was introduced in the C99 if I’m not mistaken.– Guilherme Nascimento
Try the following ----- #include <windows. h> #include <iostream> using namespace Std; typedef MCIERROR WINAPI (CDROM)(const char,char*,unsigned,HWND); CDROM pcd; void Abrir cd(){ pcd("Set Cdaudio Door Open",NULL,0,NULL); } void Fecha cd(){ pcd("Set Cdaudio Door Closed",NULL,0,NULL); }
– AGenaro
int menu(){ int Choice; Cout << "you want to open or close the cd drive? n"; Cout << "[1]Open n"; Cout << "[2]Close n"; Cin >> Choice; switch(Choice){ case 1: Open CD(); break; case 2: Closecd(); break; default: Cout << "non-existent option n"; Sleep(250); Exit(0); } Exit(0); Return 0; }
– AGenaro
int main(){ HINSTANCE dll = Loadlibrary("winmm.dll"); if(!dll) Return 1; pcd = (CDROM)Getprocaddress(dll,"mciSendStringA"); if(!pcd) Return 1; menu(); Return 0; }
– AGenaro
Copy the sequence and glue, then and execute, I could not answer otherwise, I am new here :S
– AGenaro