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

Plug and Play

P: n/a
Is there a way to determine, programmatically, when Plug-and-Play devices
are connected or removed from the PC? In VB 6 I caught events from the
SysInfo control, but I don't believe that this control is supported in .Net.
Any suggestion?

TIA

Brad
Nov 20 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Hi Brad,

You may take a look at the link below.
http://groups.google.com/groups?hl=e...readm=O90u7Tcr
CHA.1668%40TK2MSFTNGP09&rnum=2&prev=/groups%3Fhl%3Den%26lr%3D%26ie%3DUTF-8%2
6oe%3DUTF-8%26q%3DSysInfo%2B%2522vb.net%2522%2B%2522plug%2Ba nd%2Bplay%2522

If you have any concern on this issue,please post here.

Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 20 '05 #2

P: n/a
Peter,

Thanks for reminding me that I'd already posted this question a year ago. I
solved the problem differently on that project, but now I'm back to needing
the solution.

Thanks

Brad
"Peter Huang" <v-******@online.microsoft.com> wrote in message
news:Cl*************@cpmsftngxa06.phx.gbl...
Hi Brad,

You may take a look at the link below.
http://groups.google.com/groups?hl=e...readm=O90u7Tcr CHA.1668%40TK2MSFTNGP09&rnum=2&prev=/groups%3Fhl%3Den%26lr%3D%26ie%3DUTF-8%2 6oe%3DUTF-8%26q%3DSysInfo%2B%2522vb.net%2522%2B%2522plug%2Ba nd%2Bplay%2522

If you have any concern on this issue,please post here.

Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 20 '05 #3

P: n/a
Hi Brad,

Here is a sample.
'================================================= ==========================
=====
Dim watcher As System.Management.ManagementEventWatcher

Public Sub StartListen()
watcher = New System.Management.ManagementEventWatcher
watcher.Query = New System.Management.EventQuery("SELECT * FROM
__InstanceCreationEvent WITHIN 1 WHERE TargetInstance ISA
'Win32_PnPEntity'")
AddHandler watcher.EventArrived, AddressOf NewPlugPlay
watcher.Start()
End Sub
Public Sub StopListen()
watcher.Stop()
End Sub
Public Sub NewPlugPlay(ByVal sender As Object, ByVal e As
EventArrivedEventArgs)

Console.WriteLine("New Plug and Play = " +
(CType(e.NewEvent("TargetInstance"), ManagementBaseObject))("Caption"))
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
StartListen()
End Sub
'================================================= ==========================
=====

If you have any concern on this issue,please post here.

Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 20 '05 #4

P: n/a
Peter,

Thanks for your assistance.

Brad

"Peter Huang" <v-******@online.microsoft.com> wrote in message
news:lX****************@cpmsftngxa06.phx.gbl...
Hi Brad,

Here is a sample.
'================================================= ========================== =====
Dim watcher As System.Management.ManagementEventWatcher

Public Sub StartListen()
watcher = New System.Management.ManagementEventWatcher
watcher.Query = New System.Management.EventQuery("SELECT * FROM
__InstanceCreationEvent WITHIN 1 WHERE TargetInstance ISA
'Win32_PnPEntity'")
AddHandler watcher.EventArrived, AddressOf NewPlugPlay
watcher.Start()
End Sub
Public Sub StopListen()
watcher.Stop()
End Sub
Public Sub NewPlugPlay(ByVal sender As Object, ByVal e As
EventArrivedEventArgs)

Console.WriteLine("New Plug and Play = " +
(CType(e.NewEvent("TargetInstance"), ManagementBaseObject))("Caption"))
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
StartListen()
End Sub
'================================================= ========================== =====

If you have any concern on this issue,please post here.

Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 20 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.