I found a idea to stop CD ejection .
This is based on locking the volume for exclusive use.
BOOL PreventDiskEject(LPCSTR szDriveLetter, BOOL fLock=TRUE )
{
char szDevice[10];
wsprintf( szDevice,"//./%c:", szDriveLetter[0] );
HANDLE hDevice = CreateFile(
szDevice, // // drive to open... format is "/.X:"
GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL, // default security attributes
OPEN_EXISTING, // disposition
0, NULL
);
DWORD nJunk;
PREVENT_MEDIA_REMOVAL rPMR;
rPMR.PreventMediaRemoval= fLock;
// TRUE or FALSE
BOOL fResult= DeviceIoControl(
hDevice, IOCTL_STORAGE_MEDIA_REMOVAL,
&rPMR, sizeof(rPMR), NULL, 0, &nJunk, NULL
);
CloseHandle( hDevice );
return ( fResult );
}
From:Krishnaa [02-24-2003 11:07 AM]
krishna_pawar@rediffmail.com