Startsidan  ▸  Texter  ▸  Teknikblogg

Anders Hesselbom

Programmerare, skeptiker, sekulärhumanist, antirasist.
Författare till bok om C64 och senbliven lantis.
Röstar pirat.

Keep track on USB devices

2010-10-14

Microsoft provides a library for talking to USB devices as part of the .NET Framework. This is just one thing you can do with the versatile System.Management namespace. If you want to keep track on the units that are connected or removed from a computer, you can use this library for regular checks. This code, lists the name and ID of all connected devises. The code requires a reference to the System.Management namespace:

Using Mn As New System.Management.ManagementClass("Win32_USBHub")
   Using Devs As System.Management.ManagementObjectCollection _
      = Mn.GetInstances()
      For Each Dev As System.Management.ManagementObject In Devs
         Console.WriteLine(Dev.GetPropertyValue("Name").ToString())
         Console.WriteLine(Dev.GetPropertyValue("DeviceID").ToString())
      Next
   End Using
End Using

My code is written in an console application. The result will be a list of connected USB device names and their unique ID. Have fun!

Categories: Visual Basic 9

Tags: USB

Leave a Reply

Your email address will not be published. Required fields are marked *



En kopp kaffe!

Bjud mig på en kopp kaffe (20:-) som tack för bra innehåll!

Bjud på en kopp kaffe!

Om...

Kontaktuppgifter, med mera, finns här.

Följ mig

Twitter Instagram
GitHub RSS

Public Service

Folkbildning om public service.

Hem   |   linktr.ee/hesselbom   |   winsoft.se   |   80tal.se   |   Filmtips