2012-05-10 26 views

回答

0

我真的不知道,如果它可以幫助你,但是,幾個月前我曾經driveInfo檢測USB設備

也許可以爲工作檢測到您的iPhone 嘗試到這裏看看:http://msdn.microsoft.com/en-us/library/system.io.driveinfo.isready.aspx

而對於事件中,你可以試試這個:

static ManagementEventWatcher w = null; 

private static void USBHandler(){ 

WqlEventQuery q; 
ManagementScope scope = new ManagementScope("root\\CIMV2"); 
scope.Options.EnablePrivileges = true; 
    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 += USBInserted; 
    w.Start(); 
} 
private static void USBInserted(object sender, EventArgs e){ 

System.Windows.MessageBox.Show("USB inserted"); 
} 
+0

感謝您的回覆......但我必須在網絡應用程序中使用...我有另一種解決方案來檢查用戶代理。但我正在檢查每個手機,如Iphone Ipod,HTC,Android。因爲他們有自己不同的用戶代理。 –