Versão do .NET: link
Com a fonte: dotnetslackers.com/community/blogs/basharkokash/archive/2008/03/15/USB-Detection-source-code.aspx
Seção relevante:
static void AddInsetUSBHandler()
{
WqlEventQuery q;
ManagementScope scope = new ManagementScope("root\CIMV2");
scope.Options.EnablePrivileges = true;
try
{
q = new WqlEventQuery();
q.EventClassName = "__InstanceCreationEvent";
q.WithinInterval = new TimeSpan(0, 0, 3);
q.Condition = @"TargetInstance ISA 'Win32_USBControllerdevice'";
w = new ManagementEventWatcher(scope, q);
w.EventArrived += new EventArrivedEventHandler(USBAdded);
w.Start();
}
catch (Exception e)
{
Console.WriteLine (e.Message);
if (w != null)
w.Stop();
}
}