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#
  4. Receiving WM_DEVICECHANGE message from a console app

Receiving WM_DEVICECHANGE message from a console app

Scheduled Pinned Locked Moved C#
csharpjavascriptquestion
2 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.
  • E Offline
    E Offline
    Eberhard Fahle
    wrote on last edited by
    #1

    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

    D 1 Reply Last reply
    0
    • E 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

      D Offline
      D Offline
      djlove
      wrote on last edited by
      #2

      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...

      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