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. If new drive detected.. an event happens

If new drive detected.. an event happens

Scheduled Pinned Locked Moved C#
question
5 Posts 4 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.
  • S Offline
    S Offline
    Silvyster
    wrote on last edited by
    #1

    I am trying to create an application where, if new drive has been detected by the windows operating system, an event on the application is triggered. Although what i was planning to do is the application to check for new drives in a given time interval but seems like that is not the appropriate thing to do. Any suggestions?

    T L S 3 Replies Last reply
    0
    • S Silvyster

      I am trying to create an application where, if new drive has been detected by the windows operating system, an event on the application is triggered. Although what i was planning to do is the application to check for new drives in a given time interval but seems like that is not the appropriate thing to do. Any suggestions?

      T Offline
      T Offline
      TJS4u
      wrote on last edited by
      #2

      hello use the concept of threads thks

      S 1 Reply Last reply
      0
      • T TJS4u

        hello use the concept of threads thks

        S Offline
        S Offline
        Silvyster
        wrote on last edited by
        #3

        I'm actually using thread to keep on scanning on every time interval but don't you think that's not a good idea?

        1 Reply Last reply
        0
        • S Silvyster

          I am trying to create an application where, if new drive has been detected by the windows operating system, an event on the application is triggered. Although what i was planning to do is the application to check for new drives in a given time interval but seems like that is not the appropriate thing to do. Any suggestions?

          L Offline
          L Offline
          Luc Pattyn
          wrote on last edited by
          #4

          Hi, for a Control (a Form is a Control) you can override WndProc and check for wParam==WM_DEVICECHANGE That will give you an event whenever a device (such as a camera, USB memory stick, ...) gets added or removed. :)

          Luc Pattyn [Forum Guidelines] [My Articles]


          Fixturized forever. :confused:


          1 Reply Last reply
          0
          • S Silvyster

            I am trying to create an application where, if new drive has been detected by the windows operating system, an event on the application is triggered. Although what i was planning to do is the application to check for new drives in a given time interval but seems like that is not the appropriate thing to do. Any suggestions?

            S Offline
            S Offline
            Simon P Stevens
            wrote on last edited by
            #5

            Try responding to the WM_DEVICECHANGE[^] window message. A WParam value of DBT_DEVICEARRIVAL[^] should indicate a new cd/usb drive. Will probably only work if you have auto insert notification turned on for the drive. [Edit: Oops, should have hit refresh before posting. I agree with Luc]

            Simon

            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