DMITEST Code Sample

This section describes the dmitest code sample (DMITEST.EXE), a Win32 console application that uses the WBEM API to access and manipulate a DMI 2.0 enabled Win32 platform. The sample includes examples of DMI 2.0 MIF files that will be used to install components in the DMI database.

The same code reads input data from a script file, DMITEST.SCR, processes the command script, and makes appropriate WBEM API calls to access the DMI database. The application then will store the output data into a file called DMITEST.OUT.

The DMITEST application relies on the user to ensure that the DMI 2.0 Service Provider is already running on the system and that the WBEMDMIP.MOF file has already been compiled and installed into the CIMOM's repository to enable DMI operations.

The DMITEST code sample was developed using Microsoft Visual C++ version 5.0, and is in the \WBEM\SDK\COM\DMITEST directory.

The DMITEST' s MIF data

The application uses the MIF files DBTYPES1.MIF and TEMPCOM1.MIF to install three components in the DMI database and access them through the DMI provider. The DBTYPES1.MIF is installed twice.

The DMITEST.SCR script uses hard-coded path of C:\TESTMIFS for the location of the above two MIF files. To access the MIF files from a different directory, change the DMITEST.SCR file to look for the correct path.

The files included in this sample

Sample File Description
DMITEST.CPP Main source file for the DMITEST application responsible for reading and processing command scripts from the DMITEST.SCR input file and submitting DMI requests to WBEM.
DMITEST.H Header file for DMITEST.CPP module.
DMITEST.SCR Containing the DMI command scripts processed by the DMITEST application.
DMITEST.OUT DMITEST application generated output file containing the results from executing the DMI service requests.
DATATYPES.CPP Code for manipulating the OLE data types used by DMITEST.CPP.
DATATYPES.H Header file for DATATYPES.CPP.
DEFINES.H Header file of definitions used to turn off some sections of the WINDOWS.H header file not used by the application.
WBEMSVC.H Header file containing the CIMOM interface definitions.
DBTYPES1.MIF MIF file used to install a DMI component called "First Database Types MIF."
TEMPCOM1.MIF MIF file used to install a DMI component called "Test System Temporary Component."
DMITEST.DSP, DMITEST.DSW Visual C++ 5.0 project file used to build the DMITEST.EXE executable.

    To build the DMITEST module
  1. Run the Microsoft Visual C++ 5.0 Development Studio program.
  2. Load the DMITEST.DSP project file.
  3. From the BUILD menu, select SETTINGS. Choose the Preprocessor option from the C/C++ Tabbed dialog box. Set the Additional Include Directory entry to the INCLUDE directory of the WBEM SDK installed on your system.
  4. Replace the WBEMUUID.LIB module in the project files list with the one in the LIB directory of the WBEM SDK installed on your system.
  5. From the BUILD menu, select UPDATE ALL DEPENDENCIES.
  6. Rebuild the project to generate the DMITEST.EXE module.
  7. Verify that DMITEST.SCR file is in the same directory as the DMITEST.EXE module.
  8. Run the DMITEST application and view DMITEST.OUT file for the results after the program terminates.
  9. Open the DMITEST.CPP module and set breakpoints on the ProcessScriptFile( ) function, run the DMITEST application again, and observe how the application accesses DMI information through WBEM.