Hi,
there are many examples of how to list the USB devices connected to a system and also code to say when a USB device has been connected and disconnected. I am trying to modify this code to display the friendly device name, but without any success:
If e.NewEvent.ClassPath.ClassName = "__InstanceCreationEvent" Then
s += e.NewEvent.Properties("TargetInstance").Value.Properties("Antecedent").Value.ToString() + ControlChars.CrLf
s += e.NewEvent.Properties("TargetInstance").Value.Properties("Dependent").Value.ToString() + ControlChars.CrLf
MsgBox("USB inserted, the information is " + ControlChars.CrLf + s)
ElseIf e.NewEvent.ClassPath.ClassName = "__InstanceDeletionEvent" Then
s += e.NewEvent.Properties("TargetInstance").Value.Properties("Antecedent").Value.ToString() + ControlChars.CrLf
s += e.NewEvent.Properties("TargetInstance").Value.Properties("Dependent").Value.ToString() + ControlChars.CrLf
MsgBox("USB removed, the information is " + s)
Else
MsgBox(e.NewEvent.ClassPath.ClassName)
End If
Can I extract the friendly device name from the above code?
Many thanks
Lawrence
there are many examples of how to list the USB devices connected to a system and also code to say when a USB device has been connected and disconnected. I am trying to modify this code to display the friendly device name, but without any success:
If e.NewEvent.ClassPath.ClassName = "__InstanceCreationEvent" Then
s += e.NewEvent.Properties("TargetInstance").Value.Properties("Antecedent").Value.ToString() + ControlChars.CrLf
s += e.NewEvent.Properties("TargetInstance").Value.Properties("Dependent").Value.ToString() + ControlChars.CrLf
MsgBox("USB inserted, the information is " + ControlChars.CrLf + s)
ElseIf e.NewEvent.ClassPath.ClassName = "__InstanceDeletionEvent" Then
s += e.NewEvent.Properties("TargetInstance").Value.Properties("Antecedent").Value.ToString() + ControlChars.CrLf
s += e.NewEvent.Properties("TargetInstance").Value.Properties("Dependent").Value.ToString() + ControlChars.CrLf
MsgBox("USB removed, the information is " + s)
Else
MsgBox(e.NewEvent.ClassPath.ClassName)
End If
Can I extract the friendly device name from the above code?
Many thanks
Lawrence