Visual Basic.NET
  Home arrow Visual Basic.NET arrow WMI Programming with Visual Basic.NET: Tra...
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
VISUAL BASIC.NET

WMI Programming with Visual Basic.NET: Trapping System Events
By: Jagadish Chaterjee
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 5
    2005-07-25

    Table of Contents:
  • WMI Programming with Visual Basic.NET: Trapping System Events
  • Creating a simple application
  • What is “WqlEventQuery”?
  • Watching the event

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    WMI Programming with Visual Basic.NET: Trapping System Events


    (Page 1 of 4 )

    In my previous article, part five of this series, we looked at some tips and tricks for using WMI. In this article we will focus on working with trapping system events through WMI.


    You can download the zip of entire Visual Studio.NET solution (developed for this article) here.

    The first part of my series gives you the details for creating a Visual Studio.NET solution for WMI, right from the scratch. It will not be repeated any more in any of the future articles in this series.

    Can we trap system events through WMI?

    In parts four and five, we looked at managing Windows OS using WMI.  We used to call methods of the respective WMI class according to our needs. Trapping system events is also a part of managing the Windows OS. For example, all Performance Counters can be considered as event trappers of their respective events.

    The answer to the above question is “yes.” We can trap system events using WMI as our main interface. Before WMI (and even now), we needed to trap those events only through the WIN32 API. Most probably, Microsoft Visual C++ is a very flexible tool for working with the WIN32 API, as the entire WIN32 API was developed through the same language (but is difficult to understand). There is no wonder that the entire Windows OS was developed using Microsoft Visual C++.

    This article focuses on working with “trapping events” using WMI and Visual Basic.NET as core technologies. This is a bit of an advanced topic in WMI. Even though it is bit difficult to understand, try your best to follow.

    As you recall from part two of my series, I explained the “types of WQL queries." But I didn’t say much about “Event Queries” in that article. In this article, I will introduce that concept, and we will implement it.

    Let us discuss what an “event” in the Windows OS actually is. Every programmer knows that the entire Windows OS is event-driven.  Anything you operate with the Windows OS is an event. Examples of events include, but are not limited to, logging in, logging out, printing a page, installing software, opening an application, connecting to a network, stopping and starting system services, and so forth. 

    Now, say I wanted to have some script executed (such as starting an application) when someone logs in. That means my script should register to the “login” event, and continuously listen for that event to occur. When the event occurs, my script gets executed. These types of scripts (listening for events of WMI) are called consumers.  Consumers use “Event queries” to register and receive notification of events. Event providers use event queries to register (and of course listen for) one or more events. In general, the queries used for trapping event notifications are called “event queries.”

    More Visual Basic.NET Articles
    More By Jagadish Chaterjee


     

    VISUAL BASIC.NET ARTICLES

    - User-defined Functions using Visual Basic Ap...
    - Understanding Object Binding in VBA
    - Mastering the Message Box
    - Testing a Windows Forms Application
    - Using Visual Basic.NET Features to Code a Wi...
    - Correcting Code in a Windows Forms Applicati...
    - Write Readable Code and Comments for Windows...
    - How to Code and Test a Windows Forms Applica...
    - Adding Features to a Windows Forms Applicati...
    - How to Design a Windows Forms Application
    - LINQ to XML Programming Using Visual Basic.N...
    - Understanding Delegates using Visual Basic.N...
    - Create a Sudoku Puzzle Generator using VB.NET
    - Entity Creation and Messaging in a VB.NET Te...
    - Movement and Player Statistics in a VB.NET T...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 1 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek