I've been working on creating a decoupled WMI provider for about three
weeks now. As sources i've been using a combination of MSDN, the book
"Developing WMI Soutions," and, after seeing the suggestion in this
group, the "secret" examples in the Microsoft Platform SDK.
I've run into two very significant problems so far, one of which I've
solved but I'm not quite sure how, the other is still vexing me and I
was hoping someone might be able to provide some suggestions.
First the unsolved problem. I'm using the Platform SDK decoupled Event
Provider example to generate events, except that I've changed the
ProvReg.mof so the events to "MyNamespace" rather than "CimV2". The
events show up in WMI Event Viewer and seem correct there. My main
program is a combination Instance Provider and Event Consumer Provider,
both based off of the Platform SDK examples.
My program is using "MyProvider" to catch the events, and I have an
IndicateToConsumer function that just beeps whenever it gets hit:
long ObjectCount, IWbemClassObject **Objects)
It does indeed get hit whenever I run the Event Provider and starts
beeping. However then I started trying to make it do something useful,
following the guidelines in "Developing WMI Solutions." (pg. 653)
However when I try to access either the LogicalConsumer or the array of
Objects I get bad results. If I put a breakpoint in the function and
start stepping through the pointer just disapears whenever I do a Get
on LogicalConsumer or any element of Objects, and sometimes it jumps
back to the top of the function where the breakpoint is (especially if
I try to step into the offending function rather than over it) and
All three incoming pointers to the function seem troublesome.
LogicalConsumer always shows a value of 0x00d9f790, 0x017bf790 or
0x00e9f790 (switching randomly between the three) which is odd, while
ObjectCount is always 0x02020202 and Objects is always 0x00000002 which
is just plain wrong. As stated earlier the events are showing up in WMI
Event Viewer just fine and when I "View Properties" they look fine.
The two sections of code I've tried that it fails on are:
hr = LogicalConsumer->Get(CComBSTR("__CLASS"), 0, &varClass, 0, 0);
hr = Objects[i]->Get(CComBSTR("Name"), 0, &var, 0, 0);
the second one for very obvious reasons given the pointer values above.
I can post more pieces of the code if it would help, but I'm really not
sure which sections could be at fault.
The second and more trivial problem is that with my first attempt at an
InstanceProvider I was completely unable to create instances of the
classes I'd created in MyNamespace. Trying to create them in WMI Studio
resulted in "No Decoupled Providers Attached," and trying to create
them using my decoupled provider resulted in a WBEM_E_NOT_AVAILABLE
error. I finally found that if I got rid of the line "[dynamic:
ToInstance, provider ("MyProvider")]" from in front of each class,
which I'd originally included because it was suggested by the MSDN
page "Registering A Provider." I'm not exactly sure what that line was
supposed to accomplish originally or why it was causing the problems it
did. Will leaving it out cause me any more problems further down the
Thanks for any help!