Receiving WM_DEVICECHANGE message from a console app
-
The task is to do something when my USB-device gets plugged or removed. I already created some working code using an (invisible) NativeWindow that processes the WM_DEVICECHANGE messages. This has already been covered in several articles. My Windows.Forms Testapp works fine. The WM_DEVICECHANGE messages are trapped by my window and i can react to it. But could I do the same thing from a console-app?? I am able to create and register my invisible Window for notifications but the NativeWindow.Wndproc() method I have override never gets called. I guess I am missing something very basic here! Any hints in every language (not tied to c#, I will find my way around) are very Welcome. Thanks for reading Eberhard Fahle
-
The task is to do something when my USB-device gets plugged or removed. I already created some working code using an (invisible) NativeWindow that processes the WM_DEVICECHANGE messages. This has already been covered in several articles. My Windows.Forms Testapp works fine. The WM_DEVICECHANGE messages are trapped by my window and i can react to it. But could I do the same thing from a console-app?? I am able to create and register my invisible Window for notifications but the NativeWindow.Wndproc() method I have override never gets called. I guess I am missing something very basic here! Any hints in every language (not tied to c#, I will find my way around) are very Welcome. Thanks for reading Eberhard Fahle
I am just guessing that you might need a message pump, like you get when you call Application.Run in a Winforms project. If you must use Console rather than Windows forms project type then you can add an Application.Run statement into your program (once you add the relevant namespaces) and then you will receive messages. Just a hunch...