Monday, 15 July 2013

USB device Instace path usi WMI query c# -


I am trying to find the USB device instace path using the following code and always get an error about the wrong query I am here. Can anyone help me?

  string strDeviceName = "USB \\ VID_"; String Win32_PnPEntity = "Choose Win32_PnPEntity * from where deviceID like '%" + strDeviceName + "%'"; ManagementObjectSearcher mySearcher = New Management Object Search (Win32_PnPEntity); ManagementObject mobj in Forex (MySearcher.Get) {string strDeviceID = mobj ["DeviceID"]. ToString (); }  

string strDeviceName = "USB \\\\ VID_"; or string strDeviceName = @ "USB \\ VID_";

This will work if you lost a "\".


No comments:

Post a Comment