Visual Basic.NET
  Home arrow Visual Basic.NET arrow WMI Programming with Visual Basic.NET: Tra...
Iron Speed
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  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Dedicated Servers 
Download TestComplete 
Windows Web Hosting
 
IBM® developerWorks 
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 / 4
    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
     
     
    Iron Speed
     
    ADVERTISEMENT

    Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!

    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

    - Types of Operators in Visual Basic
    - Operators
    - Understanding Custom Events using Visual Bas...
    - Polymorphism using Abstract Classes in Visua...
    - Shadowing using Shadows in Visual Basic.NET ...
    - Overloading and Overriding in Visual Basic.N...
    - More on Controlling Windows Fax Services Usi...
    - Programmatically Controlling Windows Fax Ser...
    - Focusing on Forms and Menus in Visual Basic
    - Manipulating Forms with the Windows Forms Li...
    - Basics of the Windows Forms Library
    - Forms, Controls, and Other Useful Objects
    - Implementing OOP to Develop Database Oriente...
    - Using Themes and Skins for Personalization w...
    - A Deeper Look at Personalization using Visua...




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway