-
Notifications
You must be signed in to change notification settings - Fork 7
/
sshwbemhelpers.h
executable file
·771 lines (616 loc) · 20 KB
/
sshwbemhelpers.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
////////////////////////////////////////////////////////////////////////////////////////////
// SshWbemHelpers.h //
// //
// The follwing classes are defined: //
// //
// CWbemServices - threadsafe wrapper class for IWbemServices //
// CWbemClassObject - wrapper class for IWbemClassObject //
// CWbemException - wrapper for IErrorInfo, assists with WBEM error reporting //
// //
// These classes provide a convenient way to use the three most common WBEM interfaces: //
// IWbemLocator, IWbemServices, and IWbemClassObject. The also make it easy to //
// the WBEM __ExtendedStatus error object and interpret the HRESULT. The use of these //
// classes along with the smart pointers and the COM helper classes _bstr_t and //
// _variant_t can greatly reduce the chances of memory leaks in your code. //
// //
// See T_SafeVector.h for help with safe arrays and arrays of embedded objects. //
// //
// Copyright (c)1997 - 1999 Microsoft Corporation, All Rights Reserved //
////////////////////////////////////////////////////////////////////////////////////////////
#if !defined(__SdkWbemHelpers_H)
#define __SdkWbemHelpers_H
#pragma once
#pragma warning( disable : 4290) // C++ Exception Specification Ignored
#include <wbemidl.h>
/* we need this to compile properly; ch33kymix [at] whitedome.com.au*/
#pragma comment (lib, "Ws2_32.lib")
class CWbemClassObject;
class CWbemServices;
//---------------------------------------------------------------------------------------
//
// Smart pointers for the WBEM interfaces. The _COM_SMARTPTR_TYPEDEF creates smart pointer types
// named XXXPtr where XXX is the interface pointer, these types are actually classes derived from
// the COM helper class _com_ptr_t. Use these types just as you would the interface pointer, only
// AddRef and Release are called for you at the appropriate times.
//
_COM_SMARTPTR_TYPEDEF(IUnsecuredApartment, IID_IUnsecuredApartment); // IUnsecuredApartmentPtr
_COM_SMARTPTR_TYPEDEF(IWbemObjectSink, IID_IWbemObjectSink); // IWbemObjectSinkPtr
_COM_SMARTPTR_TYPEDEF(IWbemClassObject, IID_IWbemClassObject); // IWbemClassObjectPtr
_COM_SMARTPTR_TYPEDEF(IWbemServices, IID_IWbemServices); // IWbemServicesPtr
_COM_SMARTPTR_TYPEDEF(IWbemContext, IID_IWbemContext); // IWbemContextPtr
_COM_SMARTPTR_TYPEDEF(IWbemCallResult, IID_IWbemCallResult); // IWbemCallResultPtr
_COM_SMARTPTR_TYPEDEF(IWbemQualifierSet, IID_IWbemQualifierSet); // IWbemQualifierSetPtr
_COM_SMARTPTR_TYPEDEF(IWbemLocator, IID_IWbemLocator); // IWbemLocatorPtr
_COM_SMARTPTR_TYPEDEF(IWbemObjectAccess, IID_IWbemObjectAccess); // IWbemObjectAccessPtr
_COM_SMARTPTR_TYPEDEF(IEnumWbemClassObject, IID_IEnumWbemClassObject); // IEnumWbemClassObjectPtr
//---------------------------------------------------------------------------------------
// CWbemException
//
// This class assists with WBEM error handling and the WBEM __ExtendedStatus error object
//
// Create an instance of this class immediately after a WBEM call failure, and pass
// in to the constructor the HRESULT from the failed COM call and a descriptive message.
//
// Call the GetWbemError() method to retrieve the __ExtendedStatus object.
//
// This object inherits from _com_error, see _com_error documentation for information on
// how to access the encapsulated IErrorInfo interface.
//
class CWbemException : public _com_error
{
private:
CWbemClassObject * m_pWbemError;
HRESULT m_hr;
_bstr_t m_sDescription;
static IErrorInfo * GetErrorObject();
static IErrorInfo * MakeErrorObject(_bstr_t);
void GetWbemStatusObject();
public:
// use this constructor to capture the WBEM error object
// pass in the HRESULT from the failed COM call and a descriptive message
CWbemException(HRESULT hr, _bstr_t sMessage);
// use this constructor to create a generic error, does not return WBEM error
CWbemException(_bstr_t sMessage);
// returns the WBEM __ExtendedStatus object if one exists
CWbemClassObject GetWbemError();
// returns the description passed to the constructor
_bstr_t GetDescription() { return m_sDescription; }
// returns the HRESULT passed to the constructor, WBEM_E_FAILED if none passed
HRESULT GetErrorCode() { return m_hr; }
// returns the string representation of the error code for the supplied HRESULT
static _bstr_t GetWbemErrorText(HRESULT hr);
};
//-----------------------------------------------------------------------------------
// CWbemClassObject
//
// This class encapsulates a WBEM object, it transparently handles AddRef and Release.
// It also provides access to the objects methods.
//
// Assigning an instance of this object or passing it by value does not copy the
// object, only the pointer. Use Clone to make a new object. Use one of the casting
// operators to extract the underlying pointer.
//
// See IWbemClassObject for more information on the WBEM methods.
//
class CWbemClassObject
{
private:
IWbemClassObjectPtr m_pWbemObject;
// global object count for WBEM objects encapsulated by this class
// helpful for debugging
static DWORD s_dwObjectCount;
public:
// these constructors will addref the pointer
CWbemClassObject(const CWbemClassObject& _in);
CWbemClassObject(IWbemClassObject * const _in);
CWbemClassObject(IWbemClassObjectPtr& _in);
CWbemClassObject(IUnknown * _in);
CWbemClassObject(IUnknownPtr& _in);
CWbemClassObject();
~CWbemClassObject();
void Attach(IWbemClassObject * pWbemObject)
{
m_pWbemObject.Attach(pWbemObject);
}
void Attach(IWbemClassObject * pWbemObject, bool bAddRef)
{
m_pWbemObject.Attach(pWbemObject, bAddRef);
}
// this operator allows you to use the object as a pointer to
// call other IWbemClassObject methods without casting
IWbemClassObject * operator->()
{
return m_pWbemObject;
}
unsigned long GetObjectSize();
// Retrives the MOF description
_bstr_t GetObjectText()
{
_bstr_t bRet;
BSTR bstr;
if (!FAILED(m_pWbemObject->GetObjectText(0, &bstr)))
{
bRet = _bstr_t(bstr, false);
}
return bRet;
}
IWbemClassObject * Detach()
{
return m_pWbemObject.Detach();
}
// various casting operators
operator IWbemClassObject*()
{
return m_pWbemObject;
}
operator IWbemClassObject**()
{
return &m_pWbemObject;
}
operator IWbemClassObjectPtr()
{
return m_pWbemObject;
}
operator IUnknown *()
{
return (IUnknown *)(IWbemClassObject *)m_pWbemObject;
}
// address of operator
IWbemClassObject ** operator &()
{
return &m_pWbemObject;
}
// these operators allow you to check if the underlying pointer is NULL in an if statement
// just like a regular pointer
bool operator !()
{
return m_pWbemObject == NULL;
}
operator bool()
{
return m_pWbemObject != NULL;
}
bool IsNull() const
{
return m_pWbemObject == NULL;
}
// AddRef and Release
ULONG AddRef()
{
return m_pWbemObject->AddRef();
}
ULONG Release()
{
return m_pWbemObject->Release();
}
// assignment operators
IWbemClassObject* operator=(IWbemClassObject* _p)
{
m_pWbemObject = _p;
return m_pWbemObject;
}
IWbemClassObjectPtr operator=(IWbemClassObjectPtr& _p)
{
m_pWbemObject = _p;
return m_pWbemObject;
}
IWbemClassObject* operator=(IUnknown * _p)
{
m_pWbemObject = _p;
return m_pWbemObject;
}
IWbemClassObjectPtr operator=(IUnknownPtr& _p)
{
m_pWbemObject = _p;
return m_pWbemObject;
}
IWbemClassObject* operator=(const CWbemClassObject& _p)
{
m_pWbemObject = _p.m_pWbemObject;
return m_pWbemObject;
}
// make a copy of the object
HRESULT Clone(CWbemClassObject& _newObject)
{
return m_pWbemObject->Clone(_newObject);
}
// spawn a new blank instance of the object
CWbemClassObject SpawnInstance()
{
CWbemClassObject coRet;
m_pWbemObject->SpawnInstance(0, coRet);
return coRet;
}
// get a method signatures for a class
HRESULT GetMethod(const IN _bstr_t& _name, CWbemClassObject& coInSignature,
CWbemClassObject& coOutSignature, long _lFlags = 0)
{
return m_pWbemObject->GetMethod(_name, _lFlags, coInSignature, coOutSignature);
}
// this operator is defined so that the object can be stored in ordered lists
// or other structures
bool operator<(const CWbemClassObject& _comp)
{
return m_pWbemObject < _comp.m_pWbemObject;
}
/***** Get and Put property access methods */
//*** put overloads ***
HRESULT Put(const _bstr_t& _Name, _variant_t _value, CIMTYPE vType = 0)
{
return m_pWbemObject->Put(_Name, 0, &_value, vType);
}
HRESULT Put(const _bstr_t& _Name, const _bstr_t& _value, CIMTYPE vType = 0)
{
return m_pWbemObject->Put(_Name, 0, &_variant_t(_value), vType);
}
HRESULT Put(const _bstr_t& _Name, const long _value, CIMTYPE vType = 0)
{
return m_pWbemObject->Put(_Name, 0, &_variant_t(_value), vType);
}
HRESULT Put(const _bstr_t& _Name, const bool _value, CIMTYPE vType = 0)
{
return m_pWbemObject->Put(_Name, 0, &_variant_t(_value), vType);
}
//*** get overloads ***
HRESULT Get(const _bstr_t& _Name, _bstr_t& _value)
{
_variant_t v1;
HRESULT hr = m_pWbemObject->Get(_Name, 0, &v1, NULL, NULL);
_value = v1;
return hr;
}
HRESULT Get(const _bstr_t& _Name, long& _value)
{
_variant_t v1;
HRESULT hr = m_pWbemObject->Get(_Name, 0, &v1, NULL, NULL);
_value = v1;
return hr;
}
HRESULT Get(const _bstr_t& _Name, bool& _value)
{
_variant_t v1;
HRESULT hr = m_pWbemObject->Get(_Name, 0, &v1, NULL, NULL);
_value = v1;
return hr;
}
HRESULT Get(const _bstr_t& _Name, _variant_t& _value)
{
_value.Clear();
return m_pWbemObject->Get(_Name, 0, &_value, NULL, NULL);
}
_variant_t Get(const _bstr_t& _Name, CIMTYPE& vType, long& lFlavor)
{
_variant_t vRet;
m_pWbemObject->Get(_Name, 0, &vRet, &vType, &lFlavor);
return vRet;
}
_bstr_t GetString(const _bstr_t& _Name);
_int64 GetI64(const _bstr_t& _Name);
long GetLong(const _bstr_t& _Name);
bool GetBool(const _bstr_t& _Name);
_bstr_t GetCIMTYPE(const _bstr_t& _Name);
// retrieves a WBEM object embedded in a property
CWbemClassObject GetEmbeddedObject(const _bstr_t& _Name);
// use these for property enumeration
HRESULT BeginEnumeration(long _lFlags = WBEM_FLAG_LOCAL_ONLY)
{
return m_pWbemObject->BeginEnumeration(_lFlags);
}
HRESULT Next(_bstr_t& _sName, _variant_t& _value)
{
HRESULT hr;
BSTR bstr = NULL;
hr = m_pWbemObject->Next(0, &bstr, &_value, NULL, NULL);
if (hr == S_OK)
{
_sName = _bstr_t(bstr, false);
}
return hr;
}
HRESULT Next(_bstr_t& _sName, _variant_t& _value, CIMTYPE& _vartype)
{
HRESULT hr;
BSTR bstr = NULL;
_value.Clear();
hr = m_pWbemObject->Next(0, &bstr, &_value, &_vartype, NULL);
if (hr == S_OK)
{
_sName = _bstr_t(bstr, false);
}
return hr;
}
HRESULT Next(_bstr_t& _sName, _variant_t& _value, CIMTYPE& _vartype, long& _flavor)
{
HRESULT hr;
BSTR bstr = NULL;
_value.Clear();
hr = m_pWbemObject->Next(0, &bstr, &_value, &_vartype, &_flavor);
if (hr == S_OK)
{
_sName = _bstr_t(bstr, false);
}
return hr;
}
HRESULT EndEnumeration()
{
return m_pWbemObject->EndEnumeration();
}
};
// these operators are needed for storage in some data structures
__inline bool operator<(const CWbemClassObject& _X, const CWbemClassObject& _Y)
{
return _X < _Y;
}
__inline bool operator==(const CWbemClassObject& _X, const CWbemClassObject& _Y)
{
return _X == _Y;
}
//-----------------------------------------------------------------------------
// CWbemServices
//
// Provides thread safe encapsulation of the IWbemServices interface and provides
// access to it's methods. See the IWbemServices documentation for information
// about the methods.
//
// This clas also encapsulates IWbemLocator::ConnectServer(). When using this call,
// provide the address of a NULL IWbemServices pointer to act as a cache. This class
// actually stores the interface pointer in an IStream. A real interface needs
// to be kept somewhere or DCOM will garbage collect the object. When the instance
// of this class is deleted, the cached pointer still needs to be released. Use a
// smart pointer (IWbemServicesPtr) and keep it in the same scope as the
// CWbemServices instance.
//
class CWbemServices
{
private:
IWbemContextPtr m_pCtx;
IStream * m_pServicesStream; // encapsulated IWbemServices pointer
IUnknownPtr m_pUnkCache;
CRITICAL_SECTION m_cs;
bool GetInterfacePtr(IWbemServicesPtr & pServices, bool bThrowException = true);
void CommonInit(IWbemServicesPtr& pServ);
public:
// constructors will AddRef the pointer
CWbemServices(IWbemContext * _pContext = NULL);
CWbemServices(const CWbemServices& _p);
CWbemServices(const IWbemServicesPtr& _in);
CWbemServices(const IUnknownPtr& _in);
CWbemServices(IUnknown * _in);
CWbemServices(IWbemServices *_in, IWbemContext * _pContext = NULL);
~CWbemServices();
CWbemServices& operator=(IUnknown * _p);
CWbemServices& operator=(IUnknownPtr& _p);
CWbemServices& operator=(IWbemServices *_p);
CWbemServices& operator=(const CWbemServices& _p);
// when logging in, capture the IWbemServices pointer and keep it somewhere
// this pointer is stored internaly in an IStream and DCOM will garbage collect the object if
// there isn't at least one reference to it
// Login with integrated security
void ConnectServer(_bstr_t sNetworkResource, IWbemServices **_WbemServicesCache) throw(CWbemException);
// Login as a specific user
void ConnectServer
(
_bstr_t sNetworkResource,
_bstr_t sUser,
_bstr_t sPassword,
IWbemServices **_WbemServicesCache,
long lSecurityFlags = 0
) throw(CWbemException);
// create an instance a of a class given the class name
// encapsulates GetObject and SpawnInstance
CWbemClassObject CreateInstance
(
_bstr_t _sClassName,
IWbemCallResultPtr& _cr
)
{
CWbemClassObject coClassDef = GetObject(_sClassName, _cr);
CWbemClassObject coRet;
if (!coClassDef.IsNull())
{
coRet = coClassDef.SpawnInstance();
}
return coRet;
}
CWbemClassObject CreateInstance(_bstr_t _sClassName)
{
IWbemCallResultPtr crUnused;
return CreateInstance(_sClassName, crUnused);
}
HRESULT DeleteInstance
(
_bstr_t _sClass,
IWbemCallResultPtr& _cr
)
{
IWbemServicesPtr pServices;
GetInterfacePtr(pServices);
HRESULT hr = pServices->DeleteInstance(_sClass, 0, m_pCtx, &_cr);
return hr;
}
HRESULT DeleteInstance(_bstr_t _sClass)
{
IWbemCallResultPtr crUnused;
return DeleteInstance(_sClass, crUnused);
}
CWbemClassObject GetObject
(
_bstr_t _sName,
IWbemCallResultPtr& _cr,
bool _bThrowOnError = false
);
CWbemClassObject GetObject(_bstr_t _sName, bool _bThrowOnError = false)
{
IWbemCallResultPtr crUnused;
return GetObject(_sName, crUnused, _bThrowOnError);
}
HRESULT GetMethodSignatures(const _bstr_t& _sObjectName, const _bstr_t& _sMethodName, CWbemClassObject& _in, CWbemClassObject& _out)
{
HRESULT hr = E_FAIL;
CWbemClassObject methodClass = GetObject(_sObjectName);
if (methodClass)
{
hr = methodClass.GetMethod(_sMethodName, _in, _out);
}
return hr;
}
HRESULT PutInstance
(
CWbemClassObject& _object,
IWbemCallResultPtr& _cr,
long _lFlags = WBEM_FLAG_CREATE_OR_UPDATE
)
{
IWbemServicesPtr pServices;
GetInterfacePtr(pServices);
HRESULT hr = pServices->PutInstance(_object, _lFlags, m_pCtx, &_cr);
return hr;
}
HRESULT PutInstance
(
CWbemClassObject& _object,
long _lFlags = WBEM_FLAG_CREATE_OR_UPDATE
)
{
IWbemCallResultPtr crUnused;
return PutInstance(_object, crUnused, _lFlags);
}
bool IsNull()
{
IWbemServicesPtr pServices;
bool bRet = GetInterfacePtr(pServices, false) == NULL;
return bRet;
}
operator bool()
{
IWbemServicesPtr pServices;
bool bRet = GetInterfacePtr(pServices, false) != NULL;
return bRet;
}
operator int()
{
IWbemServicesPtr pServices;
bool bRet = GetInterfacePtr(pServices, false) == NULL;
return bRet;
}
HRESULT CreateInstanceEnum
(
_bstr_t Class,
long lFlags,
IEnumWbemClassObject **ppEnum
)
{
IWbemServicesPtr pServices;
GetInterfacePtr(pServices);
HRESULT hr = pServices->CreateInstanceEnum(Class, lFlags, m_pCtx, ppEnum);
return hr;
}
HRESULT CreateInstanceEnumAsync
(
_bstr_t Class,
IWbemObjectSink * ppSink,
long lFlags = 0
)
{
IWbemServicesPtr pServices;
GetInterfacePtr(pServices);
HRESULT hr = pServices->CreateInstanceEnumAsync(Class, lFlags, m_pCtx, ppSink);
return hr;
}
HRESULT CreateClassEnum
(
_bstr_t Class,
long lFlags,
IEnumWbemClassObject **ppEnum
)
{
IWbemServicesPtr pServices;
GetInterfacePtr(pServices);
HRESULT hr = pServices->CreateClassEnum(Class, lFlags, m_pCtx, ppEnum);
return hr;
}
HRESULT ExecQuery
(
_bstr_t QueryLanguage,
_bstr_t Query,
long lFlags,
IEnumWbemClassObject **ppEnum
)
{
IWbemServicesPtr pServices;
GetInterfacePtr(pServices);
HRESULT hr = pServices->ExecQuery(QueryLanguage, Query, lFlags, m_pCtx, ppEnum);
return hr;
}
HRESULT ExecQuery
(
_bstr_t Query,
long lFlags,
IEnumWbemClassObject **ppEnum
)
{
IWbemServicesPtr pServices;
GetInterfacePtr(pServices);
HRESULT hr = pServices->ExecQuery(_bstr_t("WQL"), Query, lFlags, m_pCtx, ppEnum);
return hr;
}
HRESULT ExecQuery
(
_bstr_t Query,
IEnumWbemClassObject **ppEnum
)
{
IWbemServicesPtr pServices;
GetInterfacePtr(pServices);
HRESULT hr = pServices->ExecQuery(_bstr_t("WQL"), Query, 0, m_pCtx, ppEnum);
return hr;
}
HRESULT ExecQueryAsync
(
_bstr_t Query,
IWbemObjectSink * pSink,
long lFlags = 0
)
{
IWbemServicesPtr pServices;
GetInterfacePtr(pServices);
HRESULT hr = pServices->ExecQueryAsync(_bstr_t("WQL"), Query, 0, m_pCtx, pSink);
return hr;
}
HRESULT ExecMethod
(
_bstr_t sPath,
_bstr_t sMethod,
CWbemClassObject& inParams,
CWbemClassObject& outParams
)
{
IWbemCallResultPtr crUnused;
IWbemServicesPtr pServices;
GetInterfacePtr(pServices);
HRESULT hr = pServices->ExecMethod(sPath, sMethod, 0, m_pCtx, inParams, &outParams, &crUnused);
return hr;
}
HRESULT CancelAsyncCall(IWbemObjectSink * pSink)
{
IWbemServicesPtr pServices;
GetInterfacePtr(pServices);
HRESULT hr = pServices->CancelAsyncCall(pSink);
return hr;
}
// context values are stored and used for every call until cleared
HRESULT SetContextValue(_bstr_t sName, _variant_t value);
HRESULT GetContextValue(_bstr_t sName, _variant_t& value);
HRESULT DeleteContextValue(_bstr_t sName);
HRESULT DeleteAllContextValues();
HRESULT SetContext(IWbemContext * pWbemContext);
HRESULT GetContext(IWbemContext ** ppWbemContext);
HRESULT GetServices(IWbemServices ** ppServices)
{
IWbemServicesPtr pServices;
GetInterfacePtr(pServices);
*ppServices = pServices.Detach();
return S_OK;
}
};
#endif //__SdkWbemHelpers_H