Obtaining the handle of CD drive
Hi,
I am using the following piece of code to obtain the handle to CD drive. This piece of code is working in WinXP and Win2k but its not able to get the handle in Win98.
HANDLE m_hDevice;
m_hDevice = CreateFile("\\\\?\\G:", GENERIC_READ, FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_READONLY, NULL);
if (m_hDevice==INVALID_HANDLE_VALUE)
{
AfxMessageBox("Cannot get handle");
}
Can someone help me ?
Regards
Gaurav
Re: Obtaining the handle of CD drive
What happens when you remove/change the "FILE_SHARE_WRITE"
Re: Obtaining the handle of CD drive
from MSDN
CreateFile
The CreateFile function creates or opens the following objects and returns a handle that can be used to access the object:
Consoles
Communications resources
Directories (open only)
Disk devices (Windows NT/2000 only)
^^^^^^^^^^^^^^^^^^^^^^^^^^
Files
Mailslots
Pipes
Quote:
Originally Posted by gaurav1115
Hi,
I am using the following piece of code to obtain the handle to CD drive. This piece of code is working in WinXP and Win2k but its not able to get the handle in Win98.
HANDLE m_hDevice;
m_hDevice = CreateFile("\\\\?\\G:", GENERIC_READ, FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_READONLY, NULL);
if (m_hDevice==INVALID_HANDLE_VALUE)
{
AfxMessageBox("Cannot get handle");
}
Can someone help me ?
Regards
Gaurav
Re: Obtaining the handle of CD drive
Quote:
Originally Posted by Vanaj
What happens when you remove/change the "FILE_SHARE_WRITE"
I tried but the problem persists
Re: Obtaining the handle of CD drive
Quote:
Originally Posted by wonder88
from MSDN
CreateFile
The CreateFile function creates or opens the following objects and returns a handle that can be used to access the object:
Consoles
Communications resources
Directories (open only)
Disk devices (Windows NT/2000 only)
^^^^^^^^^^^^^^^^^^^^^^^^^^
Files
Mailslots
Pipes
Thanks Dear. Do you know some other way to get the handle of CD drive in Win98.
Re: Obtaining the handle of CD drive
What was the Error you are getting...
you can get it by using GetLastError()...