Pendrive detection program

Last Edited By Krjb Donovan
Last Updated: Mar 11, 2014 07:52 PM GMT


sir i am planning to do my mini project on anti virus. but i have a problem. i should detect the pen drive name (i.e drive letter like k,j . . .).but how to detect the immediately when the drive is inserted . i want to code it in c++. so is there any way to use api functions? or else any other ways that you suggest?

    what i am planning is to execute "vol" like cmd function initially  and redirect those labels of volumes to a file f1 initially. later the same is done to another file f2 periodically. the f1 file and compared to f2. if there are any new vol then it should be another new mounted device. it is detected and the process continues to next stages.
    all this becomes burden to the cpu. every time the mounted devices are to be checked. if you have long time gaps between checks the virus might leak in to the computer. so please tell me a perfect method that all the soft wares implement. please also tell me how to implement it   .
thank you.


The way to do this is obviously platform specific.

On Windows, you could use the RegisterDeviceNotification function and then handle the WM_DEVICECHANGE message which is sent to all top-level windows.

On linux, use udev rules configured in '/etc/udev/rules.d/' which run various scripts. You can write a script which sends a signal to your program when a USB device gets connected/disconnected.


©2024 eLuminary LLC. All rights reserved.