README.md

December 5, 2022 ยท View on GitHub

Open / Close CD Tray

Description

This code just shows you how to open and close the cd tray, pretty straight forward

More Info

You need to link the lib file, winmm.lib, if you are using Dev-C++ the file is libwinmm.a

Submitted On
ByGeorge Chunni
LevelIntermediate
User Rating5.0 (10 globes from 2 users)
CompatibilityC, C++ (general)
CategoryMiscellaneous
WorldC / C++
Archive File

Source Code

// Look into the mciSendString function, it can do a lot of interesting things, Have Fun
#include <windows.h>
#include <mmsystem.h>
int main(int argc, char *argv[])
{
HWND hwnd = FindWindow(0, argv[0]); // Find our program window
ShowWindow(hwnd, SW_HIDE); // Hides it
for(;;)
{
mciSendString("Set CDAudio Door Open wait", 0, 0, 0); // Opens Cd Tray
mciSendString("Set CDAudio Door Closed wait", 0, 0, 0); // Closes CD tray
}
}