Hello, I have downloaded some coding off the internet and modified it to suit my needs. It opens and closes the CD drive ONCE. And I would like to make it do so an infinate amount of times.
#include "windows.h"
#include "winioctl.h"
#include <string>
using std::string;
int main(int argc, char* argv[])
{
string sdrive("\\\\.\\e:"); //replace 'g' by the drive letter of the cdrom
HANDLE hcd = CreateFile(sdrive.c_str(),
GENERIC_READ,
FILE_SHARE_READ,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_READONLY,
NULL);
if (hcd == INVALID_HANDLE_VALUE)
printf("Could not open drive g:\\\n");
DWORD d = 0;
DeviceIoControl(hcd, IOCTL_STORAGE_EJECT_MEDIA, NULL, 0, NULL, 0,
&d, NULL);
DeviceIoControl(hcd, IOCTL_STORAGE_LOAD_MEDIA, NULL, 0, NULL, 0,
&d, NULL);
CloseHandle(hcd);
return 0;
}
Thank you all!