I am currently writing a security tool in python that runs as a daemon on a host computer. Whenever a usb storage device is detected, it will copy all of the files from the usb to some dir on the host computer. Is there any easy way to do this sort of usb detection / interface? Thanks in advance!
Share
Yes, you need to use the
RegisterDeviceNotificationWindows API call. As far as I know, there is no Python module that wraps this functionality, so you have to usectypesto call this function.Fortunately, you are not the first person who has wanted to do this, so there are some code samples floating around the web. WxPython provides a code sample, but as you are writing a daemon this may not interest you. You might want to try the following code sample, which relies on both
ctypesandpywin32, lifted shameless from Tim Golden: