CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Feb 2008
    Posts
    28

    How to differentiate a virtual device arrival/removal than a (real) physical device?

    In my application that does some audio-related stuff, I constantly receive WM_DEVICECHANGE - DBT_DEVICEARRIVAL from the Vista Business OS, although there is no actual device arrivals nor removals. I think somewhere in the code or some other application could be adding some virtual devices on the ports, so I reckon that kicks off these events.

    I think what I should do is to try to find a way to distinguish virtual device notifications than physical device notification.

    Anyone has any idea how to achieve this?

    Thanks in advance!

  2. #2
    Join Date
    Mar 2002
    Location
    St. Petersburg, Florida, USA
    Posts
    12,125

    Re: How to differentiate a virtual device arrival/removal than a (real) physical device?

    Examine the device type???
    TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
    2008, 2009,2010
    In theory, there is no difference between theory and practice; in practice there is.

    * Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
    * How NOT to post a question here
    * Of course you read this carefully before you posted
    * Need homework help? Read this first

  3. #3
    Join Date
    Feb 2008
    Posts
    28

    Re: How to differentiate a virtual device arrival/removal than a (real) physical devi

    Thanks, but how can I examine the device type? Sorry but I am not that familiar with this area. I was handed over the code.

  4. #4
    Join Date
    Mar 2002
    Location
    St. Petersburg, Florida, USA
    Posts
    12,125

    Re: How to differentiate a virtual device arrival/removal than a (real) physical devi

    Quote Originally Posted by JoderCoder
    Thanks, but how can I examine the device type? Sorry but I am not that familiar with this area. I was handed over the code.

    Did you consider reading the documentation???

    http://msdn.microsoft.com/en-us/libr...05(VS.85).aspx

    lParam
    A pointer to a structure identifying the device inserted. The structure consists of an event-independent header, followed by event-dependent members that describe the device. To use this structure, treat the structure as a DEV_BROADCAST_HDR structure, then check its dbch_devicetype member to determine the device type.
    TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
    2008, 2009,2010
    In theory, there is no difference between theory and practice; in practice there is.

    * Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
    * How NOT to post a question here
    * Of course you read this carefully before you posted
    * Need homework help? Read this first

  5. #5
    Join Date
    Feb 2008
    Posts
    28

    Re: How to differentiate a virtual device arrival/removal than a (real) physical devi

    Ok thanks! Learnt a lot! Surely not enough!

    Another question: My code is like this

    broadcastInterface.dbcc_classguid = KSCATEGORY_AUDIO ;
    RegisterDeviceNotification(hWnd, &broadcastInterface, DEVICE_NOTIFY_WINDOW_HANDLE);

    I have to register for KSCATEGORY_AUDIO category devices. This is broad category of audio devices. But when I receive DBT_DEVICEARRIVAL, I need to take action if the arrived device is USB device only. Could you suggest any idea how to achieve this? Unfortunately registering for USB devices is not an option.

    Also if I do a check on dbcc_classguid == GUID_DEVINTERFACE_USB_DEVICE, this is not gonna happen because we registered for KSCATEGORY_AUDIO.

    But I should be able to something as the device belongs to both GUID_DEVINTERFACE_USB_DEVICE and KSCATEGORY_AUDIO group.

    Thanks much!

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