CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Aug 2005
    Posts
    3

    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

  2. #2
    Join Date
    May 2004
    Location
    45,000FT Above Nevada
    Posts
    1,539

    Re: Obtaining the handle of CD drive

    What happens when you remove/change the "FILE_SHARE_WRITE"
    Jim
    ATP BE400 CE500 (C550B-SPW) CE560XL MU300 CFI CFII

    "The speed of non working code is irrelevant"... Of course that is just my opinion, I could be wrong.

    "Nothing in the world can take the place of persistence. Talent will not; nothing is more common than unsuccessful men with talent. Genius will not; unrewarded genius is almost a proverb. Education will not; the world is full of educated derelicts. Persistence and determination are omnipotent. The slogan 'press on' has solved and always will solve the problems of the human race."...Calvin Coolidge 30th President of the USA.

  3. #3
    Join Date
    Dec 2003
    Location
    USA
    Posts
    4

    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
    Let me simply be your friend!

  4. #4
    Join Date
    Aug 2005
    Posts
    3

    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

  5. #5
    Join Date
    Aug 2005
    Posts
    3

    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.

  6. #6
    Join Date
    Aug 2004
    Location
    Chennai, India.
    Posts
    380

    Question Re: Obtaining the handle of CD drive

    What was the Error you are getting...

    you can get it by using GetLastError()...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured