Is there a way to keep XP from automatically recognizing a USB removable disk drive? In other words, I know someone who would like to plug the drive into a USB port, then mount the disk manually. (As a footnote, I argued that there was NOT a way to keep XP from automatically mounting the disk and assigning it a disk letter once it is plugged in.)
I don’t know of a way that you can disable auto-mount per se, but your friend may be able to do the equivalent depending on his/her hardware setup.
The USB ports can be enabled or disabled via the Control Panel; whether this will work for individual ports (while leaving other USB ports functional) may depend on the hardware involved. If your friend has a USB controller whose only connection is to the external drive, then he/she can disable the entire controller.
For instance, I have here a desktop PC (running XP Home) with onboard USB 1.1 ports, to which I have added a PCI card with USB 2.0 ports for use with external drives. If I right-click on “My Computer”, select “Properties”, then click on “Device Manager”, and open up “Universal Serial Bus Controllers”, I see my “USB 2.0 Root Hub”, which I can right-click on and select “Disable”. Then when I plug in an external drive, nothing is detected. By going back and “enabling” the USB 2.0, the drive will be detected and work normally. From this point on, there’s an entry for “USB Mass Storage Device” in my Device Manager, and I can turn it on and off at will by disabling and enabling either the USB 2.0 Root Hub or the Drive itself.
Maybe the above method would meet your friend’s requirements?
It sounds like that would work. One minor detail I forgot to mention, this all has to happen dynamically via software. We have dozens of USB disk devices showing up (one at a time) at various times during day.
I can think of one method: format the disk in a format not natively / conventionally understood by your operating system. Then find software that will mount the foreign-format disk but only when you run the program.
Before MacOS X supported NTFS file systems natively, you could do this with NTFS disks and using a freeware Unix command-line program to do the mounting.
You say you’re on XP, maybe you could do a similar trick with a UFS-formatted drive or something.
Thanks for the replies.
I’m thinking if can somehow hook into the XP Windows event-loop, I might be able to use some of the functions mentioned here:
The problem is, I am using Qt as the GUI, I’m not sure I can tap into the XP Windows event loop from there.
The additional information is really helpful, ccwaterback. From your OP I had imagined that your friend or colleague just wanted to do something on a home PC in an unusual way, and the answer should be limited to the “clear checkmark X on dialog box Y” level.
From your additional information, I’m now imagining a business of some kind that has an XP box with several USB hubs, each of which has several USB drives attached, so at any one moment a large number of USB drives may be physically attached, but your own GUI application activates and deactivates them according to a schedule (or based on external events). This is much more complicated, but the fact that you’re doing application programming means that you have the tools to get the job done – it’s just a matter of choosing the correct API calls.
I’ve not used Qt before; I assume that you’re talking about this, right? If so, you should be able to send and parse Windows messages, which means that you can tell Windows to enable and disable the drives at will.
A very quick search led me to hotplug.dll, which is in \windows\system32 on my XP machine. You can take a quick look at its action by clicking on Start, then Run, entering RunDLL32.EXE shell32.dll,Control_RunDLL hotplug.dll, then clicking “OK”. It should launch the “Safely Remove Hardware” dialog box, so you can see you’re on the right track.
You may want to investigate the different API functions in hotplug.dll. An alternative approach is to look at the CPIApplet Function, which will allow your program full control over the Control Panel (including enabling and disabling devices). How simple this will turn out to be will depend largely on your experience with Windows messages and callbacks.
I’m still having a little difficulty visualizing exactly what the situation is. Will someone be plugging in a USB drive at say 10:30am, then your program mounts that particular drive (among several currently connected but disabled drives?) at 11am, and shuts it down at 11:30am? How automated will the resulting solution be (i.e. can a human click a mouse button at some point, or is it all time-scheduled)?
Anyway, the “GQ” answer to the OP’s question as to whether it’s possible is “Yes, if you have a program development platform that can access the Windows API”, and further details are left to the reader.
Great stuff Antonius Block. Not getting into too many gory details, what we have is “boxes” full of USB daisy-chained devices that all have a flash disk that can be directed to connect to the USB via a program. So my program can talk to each device, tell it to connect its drive to the USB, then tell it to disconnect its drive from the USB.