SOL9 2.0 Class: SWbemObjectEx

 SOL9 C++ Class Library  SOL9 Samples  SOL9 Tutorial  SOL9 FAQ  SOL9 ClassTree 

Source code

/*
 * SWbemObjectEx.h 
 * Copyright (c) 2012 Antillia.com TOSHIYUKI ARAI. ALL RIGHTS RESERVED. 
 */


// 2012/03/08 Updated.

#pragma once

#include <sol/wmi/SWbemObject.h>


namespace SOL {

class SWbemObjectEx :public SWbemObject {
    
public:
    SWbemObjectEx(IDispatch* pDisp=NULL)
    :SWbemObject(pDisp)
    {

    }

public:
    ISWbemObjectEx* get()
    {
        return (ISWbemObjectEx*)getIDispatch();
    }
public:
    SWbemObjectEx& operator=(ISWbemObjectEx* pDisp)
    { 
        set(pDisp);
        return *this;
    }

public:
    HRESULT refresh( 
            __in long iFlags = 0,
            __in IDispatch *objWbemNamedValueSet = NULL)
    {
        HRESULT hr = E_FAIL;
        ISWbemObjectEx* object = get();

        if (FAILED(hr = object -> Refresh_( 
                iFlags,
                objWbemNamedValueSet))) {
            throw Exception(E_FAIL, "%s: %s", "E_FAIL",__FUNCTION__);
        }
        return hr;
    }        
        

public:
    //2009/12/21
    ISWbemPropertySet* getSystemProperties()
    {
        HRESULT hr = E_FAIL;
        ISWbemObjectEx* object = get();
        ISWbemPropertySet *objWbemPropertySet = NULL;

        if (FAILED(hr = object -> get_SystemProperties_( 
            &objWbemPropertySet)) {
            throw Exception(E_FAIL, "%s: %s", "E_FAIL",__FUNCTION__);
        }
        return objWbemPropertySet;
    }        

public:
    //2009/12/21
    _bstr_t getText( 
            __in WbemObjectTextFormatEnum iObjectTextFormat,
            __in long iFlags,
            __in IDispatch *objWbemNamedValueSet)
    {
        HRESULT hr = E_FAIL;
        ISWbemObjectEx* object = get();
        BSTR bsText = NULL;

        if (FAILED(hr = object -> GetText_( 
                iObjectTextFormat,
                iFlags,
                objWbemNamedValueSet,
                &bsText))) {
            throw Exception(E_FAIL, "%s: %s", "E_FAIL",__FUNCTION__);
        }
        return _bstr_t(bsText, false);
    }        

        

public:
    HRESULT setFromText( 
            __in _bstr_t bsText,
            __in WbemObjectTextFormatEnum iObjectTextFormat,
            __in long iFlags = 0,
            __in IDispatch *objWbemNamedValueSet = NULL)
        
    {
        HRESULT hr = E_FAIL;
        ISWbemObjectEx* object = get();

        if (FAILED(hr = object -> SetFromText_( 
                (BSTR)bsText,
                iObjectTextFormat,
                iFlags,
                objWbemNamedValueSet))) {
            throw Exception(E_FAIL, "%s: %s", "E_FAIL",__FUNCTION__);
        }
        return hr;
    }        

};

}

Last modified: 1 Apr 2012

Copyright (c) 2009-2012 Antillia.com ALL RIGHTS RESERVED.