Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Unmanaged DLL used by C# WPF app not receiving WM_DEVICECHANGE

Unmanaged DLL used by C# WPF app not receiving WM_DEVICECHANGE

Scheduled Pinned Locked Moved C / C++ / MFC
csharpquestionc++wpfhardware
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Leif Simon Goodwin
    wrote on last edited by
    #1

    I have a WPF application which loads two C++ DLLs. Each DLL creates a window and registers it to receive WM_DEVICECHANGE messages to detect when our hardware is connected and removed. This works fine when using one DLL. But when we use two, the second one does not receive the expected WM_DEVICECHANGE messages. And for some strange reason, the main WPF window DOES receive them. Does anyone know what is going on? And how to fix this?

    D L 2 Replies Last reply
    0
    • L Leif Simon Goodwin

      I have a WPF application which loads two C++ DLLs. Each DLL creates a window and registers it to receive WM_DEVICECHANGE messages to detect when our hardware is connected and removed. This works fine when using one DLL. But when we use two, the second one does not receive the expected WM_DEVICECHANGE messages. And for some strange reason, the main WPF window DOES receive them. Does anyone know what is going on? And how to fix this?

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      Leif Simon Goodwin wrote:

      This works fine when using one DLL. But when we use two, the second one does not receive the expected WM_DEVICECHANGE messages.

      What if you temporarily disabled the one DLL that currently works, does the other DLL then start receiving the the WM_DEVICECHANGE message?

      "One man's wage rise is another man's price increase." - Harold Wilson

      "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

      "You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles

      L 1 Reply Last reply
      0
      • D David Crow

        Leif Simon Goodwin wrote:

        This works fine when using one DLL. But when we use two, the second one does not receive the expected WM_DEVICECHANGE messages.

        What if you temporarily disabled the one DLL that currently works, does the other DLL then start receiving the the WM_DEVICECHANGE message?

        "One man's wage rise is another man's price increase." - Harold Wilson

        "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

        "You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles

        L Offline
        L Offline
        Leif Simon Goodwin
        wrote on last edited by
        #3

        That is too complex to do, but if I create a dummy WPF or WinForms project using the one that did not work, it works.

        1 Reply Last reply
        0
        • L Leif Simon Goodwin

          I have a WPF application which loads two C++ DLLs. Each DLL creates a window and registers it to receive WM_DEVICECHANGE messages to detect when our hardware is connected and removed. This works fine when using one DLL. But when we use two, the second one does not receive the expected WM_DEVICECHANGE messages. And for some strange reason, the main WPF window DOES receive them. Does anyone know what is going on? And how to fix this?

          L Offline
          L Offline
          Leif Simon Goodwin
          wrote on last edited by
          #4

          The person who wrote the DLLs used the same name for the message window in each DLL hence the bug!

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups