Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27329

USB devicename

$
0
0
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

Viewing all articles
Browse latest Browse all 27329

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>