Need some help. Windows XP Pro - Drive ejection commnands.

Overdriven

Dumpster Fire of The South
Joined
Jan 23, 2004
Messages
12,784
Okay, one of my friends and myself have been looking around google for a while looking for a MS-DOS command, as seen by the title the command was to eject my drives, my E: and F: drives to be exact.

Now, I'm wondering and asking is there a command line that can be done in dos? - He'll be running it in a batch file.

I've seen it being done in VB, but I'm not going to get myself to proper programming for a few months now, think I'll start in VB or Java or even stick to dos oO - Tried C++, I actually know where to find a good compiler.

Any help appriciated

[I'm lazy eh? :p Can't be bothered to open a online game, a older version of MSN and my WMA player xD - Fear batch files on your desktop to do it all in 2 clicks ;o]
 

Danya

Fledgling Freddie
Joined
Dec 23, 2003
Messages
2,465
There isn't a command to eject the CD tray outside of doing it in code. You can do it in C in few lines of code though. :p

And those lines are:
Code:
// replace D with the drive you want
HANDLE hCDDrive = CreateFile("\\\\.\\D:", GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
if (hCDDrive != INVALID_HANDLE_VALUE)
{
  DWORD BytesReturned;
  if (Eject) {
    DeviceIoControl(hCDDrive, IOCTL_DISK_EJECT_MEDIA, 0, 0, 0, 0, &BytesReturned, 0);
  }
  else {
    DeviceIoControl(hCDDrive, IOCTL_DISK_LOAD_MEDIA, 0, 0, 0, 0, &BytesReturned, 0);
  }
  CloseHandle(hCDDrive);
}
 

Users who are viewing this thread

Top Bottom