Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

Sample Managed Object Format (MOF) File

Visual Studio .NET 2003

A managed object format (MOF) file is an easy way to create and register providers, event categories, and events. After you create the class instances and class definitions in the MOF file, you compile it. For more information, see Compiling a Managed Object Format (MOF) File. Compiling the MOF file registers all class definitions and instances with the CIM repository. The provider, event category, and event information are then available to WMI and Visual Studio Analyzer.

The following sample illustrates the creation of class instances, the definition of a new event category, and an event class categorized under that event category.

// Copyright (c) 2000 Microsoft Corporation.
// Description:
//         mof file - Defines a custom category which derives from 
//            MSFT_AppProfRegularEvent, a custom event derived
//           from MyCustomCategory, and event provider instances needed 
//           for registration.
// **************************************************************************

instance of __Win32Provider
    Name  = "Analyzer_WMI_Event_Provider_MyProvider";
    CLSID = "{0CC9C155-B6BF-4660-8744-81FD0050AE16}";

    DefaultMachineName = NULL;
    ClientLoadableCLSID = NULL;
    ImpersonationLevel = 0;
    HostingModel = "NetworkServiceHost";

    PerUserInitialization = FALSE;
    Pure = TRUE;
    UnloadTimeout = NULL;

instance of __EventProviderRegistration
    provider = "__Win32Provider=\"Analyzer_WMI_Event_Provider_MyProvider\"";

    EventQueryList = { "select * from MyCustomEvent where SourceComponent = \"{0CC9C155-B6BF-4660-8744-81FD0050AE16}\""   };

// Provider metadata
instance of MSFT_AppProfEventProviderSetting
   // Replace the following value with your own GUID.
   ProviderGUID = "{8F366B62-E078-4388-B601-C0AB493BDDDC}";
   ProviderName = "Analyzer_WMI_Event_Provider_MyProvider";
   EventList = {"MyCustomEvent"};

// Category metadata
instance of MSFT_AppProfCategorySetting
   ClassName = "MyCustomCategory";
   Description = "My new custom category";
   ProviderGUID = "{8F366B62-E078-4388-B601-C0AB493BDDDC}";
   GUID = "{A082BC5C-E739-4EC2-B332-3AE180EE93B5}";

// New category
class MyCustomCategory : MSFT_AppProfRegularEvent 
   string MyCustomCategoryField;

// Event metadata
instance of MSFT_AppProfEventSetting
   ClassName = "MyCustomEvent";
   Description = "My new custom event";
   ProviderGUID = "{8F366B62-E078-4388-B601-C0AB493BDDDC}";
   Type = "Generic";
   GUID = "{79AE076F-777E-461B-AF40-A3D4594EA3BC}";

// New event
class MyCustomEvent :  MyCustomCategory
   string MyCustomEventField;   

See Also

Application Profiling in Windows Management Instrumentation (WMI) | WMI Event Source Setup | Registering a WMI Provider | Registering a WMI Event Category | Registering a WMI Event | Compiling a Managed Object Format (MOF) File | Generating Events in WMI | Visual Studio Analyzer Projects

© 2015 Microsoft