250 lines
9.7 KiB
C++
250 lines
9.7 KiB
C++
//***************************************************************************
|
|
|
|
//
|
|
|
|
// sample.h
|
|
|
|
//
|
|
|
|
// Module: WINMGMT class provider sample code
|
|
|
|
//
|
|
|
|
// Purpose: Genral purpose include file.
|
|
|
|
//
|
|
|
|
// Copyright (c) 1997-2001 Microsoft Corporation, All Rights Reserved
|
|
//
|
|
//***************************************************************************
|
|
|
|
#ifndef _sample_H_
|
|
#define _sample_H_
|
|
|
|
#include <wbemprov.h>
|
|
|
|
typedef LPVOID * PPVOID;
|
|
|
|
// Provider interfaces are provided by objects of this class
|
|
|
|
class CClassPro : public IWbemServices, public IWbemProviderInit
|
|
{
|
|
protected:
|
|
ULONG m_cRef; //Object reference count
|
|
IWbemServices * m_pNamespace;
|
|
public:
|
|
CClassPro(BSTR ObjectPath = NULL, BSTR User = NULL, BSTR Password = NULL, IWbemContext * pCtx=NULL);
|
|
~CClassPro(void);
|
|
|
|
//Non-delegating object IUnknown
|
|
|
|
STDMETHODIMP QueryInterface(REFIID, PPVOID);
|
|
STDMETHODIMP_(ULONG) AddRef(void);
|
|
STDMETHODIMP_(ULONG) Release(void);
|
|
|
|
//IWbemProviderInit
|
|
|
|
HRESULT STDMETHODCALLTYPE Initialize(
|
|
/* [in] */ LPWSTR pszUser,
|
|
/* [in] */ LONG lFlags,
|
|
/* [in] */ LPWSTR pszNamespace,
|
|
/* [in] */ LPWSTR pszLocale,
|
|
/* [in] */ IWbemServices *pNamespace,
|
|
/* [in] */ IWbemContext *pCtx,
|
|
/* [in] */ IWbemProviderInitSink *pInitSink
|
|
);
|
|
|
|
SCODE GetByPath( BSTR Path, IWbemClassObject FAR* FAR* pObj, IWbemContext *pCtx);
|
|
|
|
//IWbemServices
|
|
|
|
HRESULT STDMETHODCALLTYPE OpenNamespace(
|
|
/* [in] */ const BSTR Namespace,
|
|
/* [in] */ long lFlags,
|
|
/* [in] */ IWbemContext __RPC_FAR *pCtx,
|
|
/* [unique][in][out] */ IWbemServices __RPC_FAR *__RPC_FAR *ppWorkingNamespace,
|
|
/* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppResult) {return WBEM_E_NOT_SUPPORTED;};
|
|
|
|
HRESULT STDMETHODCALLTYPE CancelAsyncCall(
|
|
/* [in] */ IWbemObjectSink __RPC_FAR *pSink) {return WBEM_E_NOT_SUPPORTED;};
|
|
|
|
HRESULT STDMETHODCALLTYPE QueryObjectSink(
|
|
/* [in] */ long lFlags,
|
|
/* [out] */ IWbemObjectSink __RPC_FAR *__RPC_FAR *ppResponseHandler) {return WBEM_E_NOT_SUPPORTED;};
|
|
|
|
HRESULT STDMETHODCALLTYPE GetObject(
|
|
/* [in] */ const BSTR ObjectPath,
|
|
/* [in] */ long lFlags,
|
|
/* [in] */ IWbemContext __RPC_FAR *pCtx,
|
|
/* [unique][in][out] */ IWbemClassObject __RPC_FAR *__RPC_FAR *ppObject,
|
|
/* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppCallResult) {return WBEM_E_NOT_SUPPORTED;};
|
|
|
|
HRESULT STDMETHODCALLTYPE GetObjectAsync(
|
|
/* [in] */ const BSTR ObjectPath,
|
|
/* [in] */ long lFlags,
|
|
/* [in] */ IWbemContext __RPC_FAR *pCtx,
|
|
/* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler);
|
|
|
|
HRESULT STDMETHODCALLTYPE PutClass(
|
|
/* [in] */ IWbemClassObject __RPC_FAR *pObject,
|
|
/* [in] */ long lFlags,
|
|
/* [in] */ IWbemContext __RPC_FAR *pCtx,
|
|
/* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppCallResult) {return WBEM_E_NOT_SUPPORTED;};
|
|
|
|
HRESULT STDMETHODCALLTYPE PutClassAsync(
|
|
/* [in] */ IWbemClassObject __RPC_FAR *pObject,
|
|
/* [in] */ long lFlags,
|
|
/* [in] */ IWbemContext __RPC_FAR *pCtx,
|
|
/* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler);
|
|
|
|
HRESULT STDMETHODCALLTYPE DeleteClass(
|
|
/* [in] */ const BSTR Class,
|
|
/* [in] */ long lFlags,
|
|
/* [in] */ IWbemContext __RPC_FAR *pCtx,
|
|
/* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppCallResult) {return WBEM_E_NOT_SUPPORTED;};
|
|
|
|
HRESULT STDMETHODCALLTYPE DeleteClassAsync(
|
|
/* [in] */ const BSTR Class,
|
|
/* [in] */ long lFlags,
|
|
/* [in] */ IWbemContext __RPC_FAR *pCtx,
|
|
/* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler);
|
|
|
|
HRESULT STDMETHODCALLTYPE CreateClassEnum(
|
|
/* [in] */ const BSTR Superclass,
|
|
/* [in] */ long lFlags,
|
|
/* [in] */ IWbemContext __RPC_FAR *pCtx,
|
|
/* [out] */ IEnumWbemClassObject __RPC_FAR *__RPC_FAR *ppEnum) {return WBEM_E_NOT_SUPPORTED;};
|
|
|
|
HRESULT STDMETHODCALLTYPE CreateClassEnumAsync(
|
|
/* [in] */ const BSTR Superclass,
|
|
/* [in] */ long lFlags,
|
|
/* [in] */ IWbemContext __RPC_FAR *pCtx,
|
|
/* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler);
|
|
|
|
HRESULT STDMETHODCALLTYPE PutInstance(
|
|
/* [in] */ IWbemClassObject __RPC_FAR *pInst,
|
|
/* [in] */ long lFlags,
|
|
/* [in] */ IWbemContext __RPC_FAR *pCtx,
|
|
/* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppCallResult) {return WBEM_E_NOT_SUPPORTED;};
|
|
|
|
HRESULT STDMETHODCALLTYPE PutInstanceAsync(
|
|
/* [in] */ IWbemClassObject __RPC_FAR *pInst,
|
|
/* [in] */ long lFlags,
|
|
/* [in] */ IWbemContext __RPC_FAR *pCtx,
|
|
/* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler);
|
|
|
|
HRESULT STDMETHODCALLTYPE DeleteInstance(
|
|
/* [in] */ const BSTR ObjectPath,
|
|
/* [in] */ long lFlags,
|
|
/* [in] */ IWbemContext __RPC_FAR *pCtx,
|
|
/* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppCallResult) {return WBEM_E_NOT_SUPPORTED;};
|
|
|
|
HRESULT STDMETHODCALLTYPE DeleteInstanceAsync(
|
|
/* [in] */ const BSTR ObjectPath,
|
|
/* [in] */ long lFlags,
|
|
/* [in] */ IWbemContext __RPC_FAR *pCtx,
|
|
/* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler);
|
|
|
|
HRESULT STDMETHODCALLTYPE CreateInstanceEnum(
|
|
/* [in] */ const BSTR Class,
|
|
/* [in] */ long lFlags,
|
|
/* [in] */ IWbemContext __RPC_FAR *pCtx,
|
|
/* [out] */ IEnumWbemClassObject __RPC_FAR *__RPC_FAR *ppEnum) {return WBEM_E_NOT_SUPPORTED;};
|
|
|
|
HRESULT STDMETHODCALLTYPE CreateInstanceEnumAsync(
|
|
/* [in] */ const BSTR Class,
|
|
/* [in] */ long lFlags,
|
|
/* [in] */ IWbemContext __RPC_FAR *pCtx,
|
|
/* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler);
|
|
|
|
HRESULT STDMETHODCALLTYPE ExecQuery(
|
|
/* [in] */ const BSTR QueryLanguage,
|
|
/* [in] */ const BSTR Query,
|
|
/* [in] */ long lFlags,
|
|
/* [in] */ IWbemContext __RPC_FAR *pCtx,
|
|
/* [out] */ IEnumWbemClassObject __RPC_FAR *__RPC_FAR *ppEnum) {return WBEM_E_NOT_SUPPORTED;};
|
|
|
|
HRESULT STDMETHODCALLTYPE ExecQueryAsync(
|
|
/* [in] */ const BSTR QueryLanguage,
|
|
/* [in] */ const BSTR Query,
|
|
/* [in] */ long lFlags,
|
|
/* [in] */ IWbemContext __RPC_FAR *pCtx,
|
|
/* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler) {return WBEM_E_NOT_SUPPORTED;};
|
|
|
|
HRESULT STDMETHODCALLTYPE ExecNotificationQuery(
|
|
/* [in] */ const BSTR QueryLanguage,
|
|
/* [in] */ const BSTR Query,
|
|
/* [in] */ long lFlags,
|
|
/* [in] */ IWbemContext __RPC_FAR *pCtx,
|
|
/* [out] */ IEnumWbemClassObject __RPC_FAR *__RPC_FAR *ppEnum) {return WBEM_E_NOT_SUPPORTED;};
|
|
|
|
HRESULT STDMETHODCALLTYPE ExecNotificationQueryAsync(
|
|
/* [in] */ const BSTR QueryLanguage,
|
|
/* [in] */ const BSTR Query,
|
|
/* [in] */ long lFlags,
|
|
/* [in] */ IWbemContext __RPC_FAR *pCtx,
|
|
/* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler) {return WBEM_E_NOT_SUPPORTED;};
|
|
|
|
HRESULT STDMETHODCALLTYPE ExecMethod( const BSTR, const BSTR, long, IWbemContext*,
|
|
IWbemClassObject*, IWbemClassObject**, IWbemCallResult**) {return WBEM_E_NOT_SUPPORTED;}
|
|
|
|
HRESULT STDMETHODCALLTYPE ExecMethodAsync( const BSTR, const BSTR, long,
|
|
IWbemContext*, IWbemClassObject*, IWbemObjectSink*) {return WBEM_E_NOT_SUPPORTED;}
|
|
|
|
};
|
|
|
|
typedef CClassPro *PCClassPro;
|
|
|
|
// This class is the class factory for CClassPro objects.
|
|
|
|
class CProvFactory : public IClassFactory
|
|
{
|
|
protected:
|
|
ULONG m_cRef;
|
|
|
|
public:
|
|
CProvFactory(void);
|
|
~CProvFactory(void);
|
|
|
|
//IUnknown members
|
|
STDMETHODIMP QueryInterface(REFIID, PPVOID);
|
|
STDMETHODIMP_(ULONG) AddRef(void);
|
|
STDMETHODIMP_(ULONG) Release(void);
|
|
|
|
//IClassFactory members
|
|
STDMETHODIMP CreateInstance(LPUNKNOWN, REFIID
|
|
, PPVOID);
|
|
STDMETHODIMP LockServer(BOOL);
|
|
};
|
|
|
|
typedef CProvFactory *PCProvFactory;
|
|
|
|
|
|
|
|
// These variables keep track of when the module can be unloaded
|
|
|
|
extern long g_cObj;
|
|
extern long g_cLock;
|
|
|
|
// General purpose utilities.
|
|
|
|
|
|
SCODE CreateInst( IWbemServices * pNamespace, LPWSTR pKey, long lVal,
|
|
IWbemClassObject ** pNewInst,
|
|
WCHAR * pwcClassName,
|
|
IWbemContext *pCtx);
|
|
SCODE CreateClass( IWbemServices * pNamespace, IWbemClassObject ** pNewInst,
|
|
WCHAR * pwcClassName,
|
|
IWbemContext *pCtx);
|
|
|
|
typedef struct {
|
|
WCHAR * pwcKey;
|
|
long lValue;
|
|
} InstDef;
|
|
|
|
extern InstDef MyDefs[];
|
|
extern long glNumInst;
|
|
|
|
|
|
#endif
|