By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,569 Members | 1,615 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,569 IT Pros & Developers. It's quick & easy.

getting USB connection

P: n/a
hi, iim trying to write a driver for an mp3 player i have. ive been looking
on google for hours, but nothing i try works...i was wondering if anyone
could point me in the right ditrection on why my code wont work...thanks

Private wmiEventHandler As New Management.EventArrivedEventHandler(AddressOf
Private WithEvents wmiEventWatcher As Management.ManagementEventWatcher
Private WithEvents wmiOperationObser As New
Private wmiEventQuery As New Management.WqlEventQuery
Public Sub GetWmi()

Dim scope As New Management.ManagementScope("root\CIMV2")

scope.Options.EnablePrivileges = True


wmiEventQuery.EventClassName = "__InstanceCreationEvent"
wmiEventQuery.WithinInterval = New TimeSpan(0, 0, 10)
wmiEventQuery.Condition = "TargetInstance ISA
'Win32_USBControllerDevice' "

wmiEventWatcher = New Management.ManagementEventWatcher(scope,


Catch ex As Exception


End Try

End Sub

Public Sub UsbEventArrived(ByVal sender As Object, ByVal e As
Management.EventArrivedEventArgs) Handles wmiEventWatcher.EventArrived

''Get the Event object and display it
For Each pd As Management.PropertyData In e.NewEvent.Properties

''ExtendedObject is a temp name, its a class inherited from TreeNode.
''only adds new string properties
Dim obj As New ExtendedObject

Dim mbo As Management.ManagementBaseObject = CType(pd.Value,

obj.Name = pd.Name
obj.Text = pd.Name
obj.Type = pd.Type.ToString()
obj.Value = pd.Value
obj.Origin = pd.Origin

''once this line is hit, the sub is exited

''second time through, once the code gets here, the sub is exited
If mbo IsNot Nothing Then

For Each prop As Management.PropertyData In mbo.Properties

Dim obj2 As New ExtendedObject

obj2.Name = prop.Name
obj2.Value = prop.Value



End If


End Sub

Nov 15 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.

Browse more Visual Basic .NET Questions on Bytes