hDevice = CreateFile("\\\\.\\s:", // drive to open
GENERIC_READ, // | GENERIC_WRITE, // don't need any access to the drive
FILE_SHARE_READ | FILE_SHARE_WRITE, // share mode
NULL, // default security attributes
OPEN_EXISTING, // disposition
0, // file attributes
NULL); // don't copy any file's attributes
file://I then try to Lock the drive with,
// for (int abcd=0; abcd < 20; abcd++)
bResult = DeviceIoControl(
hDevice, // handle to a volume
FSCTL_LOCK_VOLUME, // dwIoControlCode operation
NULL, // lpInBuffer; must be NULL
0, // nInBufferSize; must be zero
NULL, // lpOutBuffer; must be NULL
0, // nOutBufferSize; must be zero
lpBytesReturned, // number of bytes returned
lpOverlapped // OVERLAPPED structure
);
junk = GetLastError();
if (junk)
ShowGetLastError(junk);
if (!bResult)
{ // if IOCTL failed...
CloseHandle(hDevice); // we're done with the handle
return (FALSE);
}
But I get Unhandled exception in LockDrive.exe (Kernal32.dll) 0xC0000005:
Access Violation. I was then going to FSCTL_DISMOUNT_VOLUME then
IOCTL_STORAGE_MEDIA_REMOVAL then IOCTL_STORAGE_EJECT_MEDIA. What am I doing
wrong?
If anyone want to email me code that would be great.
My CDROM drive is a SCSI unit. I am running Windows 2000 with Administrative
rights. There is a CD in the drive.
Thanks,
Allan
"whitemous" <whit...@nospam.org> wrote in message
news:kQhZ4.56712$nl3.1...@typhoon.ne.mediaone.net...
LPDWORD lpBytesReturned;
silly me,
it's now
LPDWORD lpBytesReturned;
DWORD BytesReturned;
lpBytesReturned = &BytesReturned;
Thanks
"David Wendt" <we...@us.ibm.com> wrote in message
news:8h87aa$sq8$1...@news2atm.raleigh.ibm.com...
[ ... ]
There's a much easier way. Try:
mciSendString("set cdaudio door open");
--
Later,
Jerry.
The universe is a figment of its own imagination.