none
WM_DEVICECHANGE - not for data storage devices RRS feed

  • Question

  • Hello,

    I remember about 5 years ago there were some problem to be resolved in normal way, for to be added to a robust code..

    And the problem is how to serve WM_DEVICECHANGE when you want to catch other from data storage media devices.

    For the instance say let it be an external sound card, or web camera and such.

    When the WM_DEVICECHANGE comes at removal - it's fired one time, but on ARRIVAL .. many times.. 4 or 5 times..

    I was doing some pulser thread, and it was waiting for the last message and then refreshed the device list in a comboBox.

    It was really ugly solution..  the great idea was to add to Windows WM_DEVICECHANGE an edditional lParam or wParam where some constant would say REMOVED or ARRIVED.. just like we do it in any of Async operations.

    Do you know if there is already any cool code to control the ending of the WM_DEVICECHANGE to let me to refresh device list in dialog?


    "I = I + 1" .. Isn't it boolshit?


    • Edited by RobbKirk Monday, November 11, 2019 4:40 AM
    Monday, November 11, 2019 3:14 AM

Answers

  • Hi RobbKirk, 

    Thank you for posting here.

    I note that WM_DEVICECHANGE message is used to notify an application of a change to the hardware configuration of a device or the computer, so I have two questions to confirm with you.

    Do you want to know how to use WM_DEVICECHANGE to detect data changes in data storage device or addition and removal of the data storage device?

    >> control the ending of the WM_DEVICECHANGE to let me to refresh device list in dialog

    Could you provide more details about this sentence? It will help us to analyze your problem.

    We are waiting for your update.

    Besides, I find a reference about detecting hardware changes.

    Check for device change (add/remove) events

    Best Regards,

    Xingyu Zhao


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    Tuesday, November 12, 2019 2:54 AM
    Moderator

All replies

  • Hi RobbKirk, 

    Thank you for posting here.

    I note that WM_DEVICECHANGE message is used to notify an application of a change to the hardware configuration of a device or the computer, so I have two questions to confirm with you.

    Do you want to know how to use WM_DEVICECHANGE to detect data changes in data storage device or addition and removal of the data storage device?

    >> control the ending of the WM_DEVICECHANGE to let me to refresh device list in dialog

    Could you provide more details about this sentence? It will help us to analyze your problem.

    We are waiting for your update.

    Besides, I find a reference about detecting hardware changes.

    Check for device change (add/remove) events

    Best Regards,

    Xingyu Zhao


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    Tuesday, November 12, 2019 2:54 AM
    Moderator
  • Hello Xingyu Zhao,

    Thank you for your support.

    How to use it for determination of a data storage USB device I know.. and it's widely distributed over the network. But I have to do it with other devices, like WebCam or external soundCard connected to USB and so on.
    Now what I do, I just catch that event and if the device is plugged, I receive about 4 or 5 such events, like pulsation of that even :) I do some delay mechanism to let that pulsations to stop and then re-read WaveIn and WaveOut devices to populate the combobox with fresh data.

    When the device is disconnected, I receive it only once, and it's Ok.

    I just wanted to get rid of that "pulsation problem" and to be able to get it once, as it supposed to be if the device Type is requested to me.


    "I = I + 1" .. Isn't it boolshit?

    Tuesday, November 26, 2019 11:46 PM
  • Hi RobbKirk, 

    Thanks for your feedback.

    From your description, I suggest you ask your question in Windows Desktop Development forums for more help.

    Besides, I find a reference about detecting media insertion or removal.

    Detecting Media Insertion or Removal

    I hope it could be helpful.

    Best Regards,

    Xingyu Zhao


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, November 28, 2019 9:35 AM
    Moderator
  • Xingyu Zhao,

    Thank you, the solution in Stockoverflow resolved my problem!

    Best Regards!!!


    "I = I + 1" .. Isn't it boolshit?

    Sunday, December 1, 2019 9:12 AM