Start New Discussion Reply to this Discussion Detecting new usb removable devices using c++
Hi guys, how are you?
Well, i have my science fair soon and i want to build a software that can copy any given file to any removable device that gets connected to the computer it is running on.. But the problem is i dont know how to do this... I am not that good in c++... So please help me..
In a simpler way, i am trying to write a c++ function that can copy lets say the file "exam.pdf" to any usb device that gets connected to the computer running the software containing that function.. How can i do it?? I looked on google and nothing useful came to me... Please people help me! And i will be greatful to anyone who will try to help!!
Related Article: C/C++ Matrix Algorithm
is a solved C++ discussion thread by Vectorizm that has 14 replies, was last updated 11 months ago and has been tagged with the keywords: c, c++, matrix, algorithm.
Awah Mohamed
Junior Poster
176 posts since Jul 2010
Reputation Points: 5
Solved Threads: 2
Skill Endorsements: 0
The function should do everything automatically.. Like it should automatically detect the new device and automatically send to it the file...
Awah Mohamed
Junior Poster
176 posts since Jul 2010
Reputation Points: 5
Solved Threads: 2
Skill Endorsements: 0
You have to handle the WM_DEVICECHANGE message in the window procedure of the application. The WPARAM will be the device change event such as DBT_DEVICEARRIVAL or DBT_DEVICEREMOVECOMPLETE. LPARAM is a pointer to the device broadcast header. You can detect the device type which is stored in the dbch_devicetype member of PDEV_BROADCAST_HEADER.
There is one "gotcha" with this scenario. The system will only send a WM_DEVICECHANGE message to the application with a top level window. To eliminate this "gotcha", you must use the RegisterDeviceNotification function to allow your app to be notified upon any interface changes. Thus, allowing your application to receive the WM_DEVICECHANGE message even if it is not a top level window.
BobS0327
Junior Poster
185 posts since Feb 2008
Reputation Points: 35
Solved Threads: 24
Skill Endorsements: 0
© 2013 DaniWeb® LLC
Page generated in 0.0578 seconds
using 2.66MB