|
The samples contained within
this directory are intended to demonstrate the concepts of building Windows
Management Instrumentation (WMI) applications and providers using Microsoft
Visual C++. Examples of property,
method, instance and event providers as well as consumer applications for
various types of provider information are included. In addition, a simple provider based on the WMI Provider
Framework is presented to streamline and simplify the process of building your
own provider.
A list of the samples
and a brief description of their purpose is provided below.
Provider Samples
Sample Name |
Description |
ClassProv |
An example of a WMI
class provider. |
EventProvider |
An example of an
event provider. The provider generates
periodic events, which can be collected by the TempConsumer client
application. |
FrameworkProv |
An example of an
instance provider built on the WMI Provider Framework. The
sample code supports enumeration, retrieval, put and delete. |
HiPerfProvider |
An example of a
provider that uses the high performance API.
This provider can be used in conjunction with the HiPerfClient sample. |
InstProv |
An example of a basic
instance provider. |
MethProv |
An example of a basic
methods provider. This provider can
be used in conjunction with the MethCli sample client application. |
PropProv |
An example of a basic
property provider. |
Client Samples
Sample Name |
Description |
Client |
An MFC-based sample client
that demonstrates many useful operations a typical WMI client application
might perform. Concepts such as
connecting to CIMOM, retrieving instances of the Win32 provider classes,
creating new namespaces and user classes and adding temporary and permanent
event consumer are demonstrated. |
CmdLineConsumer |
A simple event
consumer that looks for instance creation events. If an instance creation event is received, the sample launches
a user-specific application (Windows Notepad, by default). |
CustomViews |
This sample
demonstrates how to use the Custom View OCX’s controls used by the WMI SDK
applications to get custom views of information available via WMI. |
EventConsumer |
The EventConsumer
sample is an example of an event consumer provider. This provider implements the
IWBEMEventConsumerProvider. The
sample also includes the event consumer that is returned by the even consumer
provider. The event consumer
demonstrates the implementation of the IWBEMUnboundObjectSink interface which
actually consumes WMI events. |
HiPerfClient |
This sample
demonstrates a client that makes use of the WMI high performance API. This client should be used in conjunction
with the HiPerfProvider sample provider. |
MethCli |
This sample demonstrates
a client for a method provider. This
client can be used in conjunction with the MethProv sample provider. |
PingWbem |
This sample
demonstrates the simplest WMI feature, connecting to the Windows Management
service (CIMOM). |
SimpleClient |
The SimpleClient
sample code is meant to accompany the tutorial article "Creating a WMI
Application in MFC". |
TempConsumer |
The TempConsumer
sample demonstrates a temporary asynchronous event consumer application. TempConsumer consumes events produced by the provider in
the EventProvider WMI SDK sample. |
WbemDump |
The WbemDump sample
application allows the user to dump the contents of the CIMOM database to the
console or a file. |
Other Samples
Sample Name |
Description |
UtilLib |
The UtilLib sample
library is a collection of useful routines used by some of the samples
applications and that can be used in general for building WMI applications. |
General
Notes
Things to remember when you're building your own
WMI client applications and providers:
1.
If you want your
client to run on NT and non-DCOM versions of Windows 95, manually load the ole32.dll
and see if CoInitializeSecurity() exists. This routine won’t exist on Windows
95 installations that don’t have DCOM installed separately. If this routine
doesn't exist, the asynchronous routines in this sample won’t work because of
mismatched security level problems. The synchronous techniques will still work.
2.
If you don’t care
about non-DCOM versions of Windows 95, you can define _WIN32_DCOM
so that CoInitializeSecurity() is available for implicit linking. Don't use
_WIN32_WINNT to get this prototype since it won't compile under the Windows
95/98 operating systems.
3.
In any case, the
CoInitializeSecurity() call (in InitInstance()) is required to work around a
security problem when WMI trying to call a Sink object but won't identify
itself. The CoInitializeSecurity() call turns off the authentication
requirement.
4.
WMI interfaces are
defined in wbemcli.h and wbemprov.h found in the wbem\include directory. You may #include both these files by including just wbemidl.h
located in the same directory.
5.
WMI interface CLSIDs
are defined in wbemuuid.lib. If you get unresolved externals in interfaces and
CLSIDs, this is what is missing.
6.
You'll need to link
with oleaut32.lib and ole32.lib to get the needed COM support.
7.
In the Link|Output
settings, specify 'wWinMainCRTStartup' as the entry point. This is per the
Unicode programming instructions.
8.
If you're using the makefiles, don't forget to set the Visual C++
environment variables. This is done by running VCVARS32.BAT.
9.
You may get errors
attempting to build or run Unicode configurations of the MFC-based
samples. The Unicode versions of the
MFC libraries are not copied to your hard drive unless you select them during a
Custom installation of VC++. They are not copied during other types of
installation. To copy the files to your hard drive, rerun Setup, choose Custom
installation, clear the check boxes for all other components except
"Microsoft Foundation Class Libraries," click the Details button, and
select both "Static Library for Unicode" and "Shared Library for
Unicode."