Click here to Skip to main content
15,904,823 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionCD ROM open close problem Pin
p_5-Sep-07 19:22
p_5-Sep-07 19:22 
hi all vc++ masters \
i use this code for cd rom open and close
but this gives

'OpenVolume' : local function definitions are illegal
'OpenVolume' : cannot convert parameter 1 from 'char [3]' to 'char'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast

NOTE:the line contain stars shows errors;

DWORD IOCTL_STORAGE_EJECT_MEDIA;
DWORD bytesreturned;
HANDLE OpenVolume(TCHAR cDriveLetter)
****{HANDLE hVolume;
UINT uDriveType;
TCHAR szVolumeName[8];
TCHAR szRootName[5];
DWORD dwAccessFlags;

wsprintf(szRootName, szRootFormat, cDriveLetter);

uDriveType = GetDriveType(szRootName);
switch(uDriveType) {
case DRIVE_REMOVABLE:
dwAccessFlags = GENERIC_READ | GENERIC_WRITE;
break;
case DRIVE_CDROM:
dwAccessFlags = GENERIC_READ;
break;
default:
_tprintf(TEXT("Cannot eject. Drive type is incorrect.\n"));
return INVALID_HANDLE_VALUE;
}

wsprintf(szVolumeName, szVolumeFormat, cDriveLetter);

hVolume = CreateFile( szVolumeName,
dwAccessFlags,
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL,
OPEN_EXISTING,
0,
NULL );
if (hVolume == INVALID_HANDLE_VALUE)
ReportError(TEXT("CreateFile"));

return hVolume;
}
*****HANDLE hVolume = OpenVolume("D:");DeviceIoControl( hVolume, IOCTL_STORAGE_EJECT_MEDIA, NULL, 0, NULL, 0, &bytesreturned, NULL );
thanks

special thanks to MR Naveen
AnswerRe: CD ROM open close problem Pin
nitin35-Sep-07 20:07
nitin35-Sep-07 20:07 
GeneralRe: CD ROM open close problem Pin
p_5-Sep-07 20:23
p_5-Sep-07 20:23 
GeneralRe: CD ROM open close problem Pin
nitin35-Sep-07 20:41
nitin35-Sep-07 20:41 
GeneralRe: CD ROM open close problem Pin
p_5-Sep-07 22:10
p_5-Sep-07 22:10 
QuestionWindows Filtering Platform Pin
shiraztk5-Sep-07 19:02
shiraztk5-Sep-07 19:02 
QuestionCan anybody tell me how to find out the drive partitioning of a stand alone machine using c++ Pin
philiptabraham5-Sep-07 18:12
philiptabraham5-Sep-07 18:12 
QuestionRecording keystrokes Pin
hxhl955-Sep-07 18:11
hxhl955-Sep-07 18:11 
QuestionRe: Recording keystrokes Pin
baerten5-Sep-07 20:59
baerten5-Sep-07 20:59 
AnswerRe: Recording keystrokes Pin
GauranG Shah6-Sep-07 0:40
GauranG Shah6-Sep-07 0:40 
QuestionRe: Recording keystrokes Pin
hxhl956-Sep-07 17:13
hxhl956-Sep-07 17:13 
Questionout-of-proc server COM Pin
George_George5-Sep-07 18:04
George_George5-Sep-07 18:04 
AnswerRe: out-of-proc server COM Pin
DevMentor.org6-Sep-07 8:23
DevMentor.org6-Sep-07 8:23 
GeneralRe: out-of-proc server COM Pin
George_George6-Sep-07 17:28
George_George6-Sep-07 17:28 
QuestionBinary Search Trees Pin
sirtimid5-Sep-07 17:36
sirtimid5-Sep-07 17:36 
Questionweekday in number Pin
includeh105-Sep-07 16:52
includeh105-Sep-07 16:52 
AnswerRe: weekday in number Pin
bob169725-Sep-07 17:00
bob169725-Sep-07 17:00 
AnswerRe: weekday in number Pin
Michael Dunn5-Sep-07 17:16
sitebuilderMichael Dunn5-Sep-07 17:16 
QuestionExtremely weird: CEdit scrollbar not redrawn after SetBitmap() operation Pin
abiemann5-Sep-07 14:58
abiemann5-Sep-07 14:58 
AnswerRe: Extremely weird: CEdit scrollbar not redrawn after SetBitmap() operation Pin
Naveen5-Sep-07 16:36
Naveen5-Sep-07 16:36 
GeneralRe: Extremely weird: CEdit scrollbar not redrawn after SetBitmap() operation Pin
abiemann6-Sep-07 6:27
abiemann6-Sep-07 6:27 
GeneralRe: Extremely weird: CEdit scrollbar not redrawn after SetBitmap() operation Pin
Naveen6-Sep-07 14:02
Naveen6-Sep-07 14:02 
QuestionGetPrivateProfileString method: problems on Windows Vista Pin
Cris5-Sep-07 10:10
Cris5-Sep-07 10:10 
AnswerRe: GetPrivateProfileString method: problems on Windows Vista Pin
David Crow5-Sep-07 10:38
David Crow5-Sep-07 10:38 
GeneralRe: GetPrivateProfileString method: problems on Windows Vista Pin
Cris5-Sep-07 10:41
Cris5-Sep-07 10:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.