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