Syndication : Atom 1.0  RSS 2.0
Blogs des développeurs   »   .: Ogotcha :.

Article complet: Détection périphérique USB

21/11/2008

Permalink 11:06:59, Catégories: Récapitulatif .NET, VB.Net, Astuces, 151 mots   French (FR) , Ogotcha

[.NET] Détection périphérique USB

Voilà après un certain nombre de recherches (infructueuses) j'ai enfin trouvé comment intercepter la connexion et la déconnexion d'un périphérique USB.

Merci WMI ;).

Code:
 
Imports System.Management 'A ajouter aussi dans vos référence projet 
 
Dim WithEvents ManagEvent As ManagementEventWatcher 
Dim QueryEvent As WqlEventQuery 
 
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 
  QueryEvent = New WqlEventQuery("Select * from Win32_DeviceChangeEvent") 
  ManagEvent = New ManagementEventWatcher(QueryEvent) 
  ManagEvent.Start() 
End sub 
 
Private Sub Form1_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing 
  ManagEvent.Stop() 
End Sub 
 
Private Sub ManagEvent_EventArrived(ByVal sender As Object, ByVal e As System.Management.EventArrivedEventArgs) Handles ManagEvent.EventArrived 
  'Evenement lors de la détection 
End Sub 

Social Bookmarking:

                                     

Commentaires, Pingbacks:

Connectez-vous pour vous abonner à cet article:

Flux de commentaires pour cet article : Atom 1.0  RSS 2.0

Cet article n'a pas de Commentaires/Pingbacks pour le moment...

Vous devez être identifié pour poster un commentaire.

.: Ogotcha :.

Blog d'Ogotcha
Mon blog est là essentiellement pour partager mon expérience dans le monde du développement.

Catégories


Rechercher

<  Février 2012  >
Lun Mar Mer Jeu Ven Sam Dim
    1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29        

Syndiquez ce blog XML

Articles :

Commentaires :

 
 
 
 
Partenaires

Hébergement Web