USB ejection
-
You know in Windows xp or 2000, there is still the possibility of loosing data if you just yank out your flash drive, but to do it the proper way, you must go through a series of annoying dialogs. If I have the user enter their drive letter, for which the letter would be stored in the registry or something, Is there something I can access in Windows to programatically eject the drive without having to go through all those dialogs. For instance, simply run the app from the desktop with an invisible form that would exit once it had ejected (successfully) your drive. This would be very helpful to me, thanks!!!
-
You know in Windows xp or 2000, there is still the possibility of loosing data if you just yank out your flash drive, but to do it the proper way, you must go through a series of annoying dialogs. If I have the user enter their drive letter, for which the letter would be stored in the registry or something, Is there something I can access in Windows to programatically eject the drive without having to go through all those dialogs. For instance, simply run the app from the desktop with an invisible form that would exit once it had ejected (successfully) your drive. This would be very helpful to me, thanks!!!
There's nothing in the .NET FCL that will do this. You'll have to use the Win32 API DeviceIoCtl functions to get at the USB bus, enumerate it, find the device your looking for, then build the appropriate IOCTL message and send it to the Device Manager. There is very little information around to do this, so you'll have to do a bunch of your own research. A Managed C++ .DLL might help you out alot in this situation, saving you from P/Invoking the Device Management functions and structures. Google for "USB C# DeviceIoControl" and you should come up with at least a few tidbits to get you started. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
-
You know in Windows xp or 2000, there is still the possibility of loosing data if you just yank out your flash drive, but to do it the proper way, you must go through a series of annoying dialogs. If I have the user enter their drive letter, for which the letter would be stored in the registry or something, Is there something I can access in Windows to programatically eject the drive without having to go through all those dialogs. For instance, simply run the app from the desktop with an invisible form that would exit once it had ejected (successfully) your drive. This would be very helpful to me, thanks!!!
Dialogs? Have you tried left-clicking the "safely remove hardware" icon in the system tray, which will popup a menu, and pick the device to unload? It should be that simple. -- Joel Lucsy