I'm looking for a C # code snippet to tell me when a USB drive is connected to my computer in Windows Vista (or win7)
Codeproject has a class called DriveDetector that sounds like it does what you want.
Take a look at WM_DEVICECHANGE . This message should be sent when a disc is inserted.
, , , , , . WMI System.Management, , .
, , . , , USB-.
powershell, System.Management.ManagementEventWatcher WMI Win32_VolumeChangedEvent, , , PowerShell, .. :
http://www.nivot.org/nivot2/post/2008/08/16/AutoMountunmountNewPSDrivesForRemovableDrivesAndNetworkSharesInPowerShellV2.aspx
#, , script.
, .