You should specify on what language you want to implement it.
In .NET it's more easy to make: you should declare class with fields which you planning to pass as an event arguments. The class should have fields only and have class attribute
InstrumentationClass
set as event.
[InstrumentationClass(InstrumentationType.Event)]
public class MyEvent
{
public string Text;
}
To raise event you should create instance of your object, set fields and call
Instrumentation.Fire
var _event = new MyEvent();
_event.Text = "Some Text";
Instrumentation.Fire(_event);
To specify WMI root use
Instrumented
assembly attribute:
[assembly: Instrumented("root/default")]
To have installer you can use the default one:
[System.ComponentModel.RunInstaller(true)]
public class WMIProviderInstaller : DefaultManagementProjectInstaller { }
Install the provider before posting the event.
The C++ implementation is more heavy. You should create *.mof file of your provider and also declare the event class and it fields. Setup that mof file into WMI with mof registration tool.
In provider COM object you should implement
IWbemEventProvider
and
IWbemProviderInit
. In initialization method you request for the
IWbemClassObject
of the type you interested from the connected namespace. To raising evens you initiate instance of the
IWbemClassObject
object by using
IWbemClassObject->SpawnInstance
and set fields as COM Variants based on fields you declared in the mof file. And the call the
IWbemObjectSink->Indicate
with initialized event.
For the remote connection you should configure security settings.
For testing you can use your own application or any script language which allow to perform wmi query, or the wbemtest tool.
Regards,
Maxim.