⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wiapropertymanager.cpp

📁 winddk src目录下的WDM源码压缩!
💻 CPP
📖 第 1 页 / 共 3 页
字号:
}

/*****************************************************************************
   Function Name: AddProperty

   Arguments:

   LONG lPropertyID  - Property ID
   LPOLESTR szName   - Property NAME
   LONG lAccessFlags - Property Access Flags
   LONG lCurrValue   - Current Property Value
   LONG lValidBits   - Valid bit values

   Description:

   This function adds a new property to the property list.

   Remarks:
   If a property exists with the same property ID:
        1. The old property is removed from the list, and the contents
           destroyed
        2. The new property is added to the list.

 *****************************************************************************/


HRESULT CWIAPropertyManager::AddProperty(LONG lPropertyID, 
                                         __in LPOLESTR szName, 
                                         LONG lAccessFlags, 
                                         LONG lCurrValue, 
                                         LONG lValidBits)
{

    HRESULT hr = E_INVALIDARG;
    if(szName)
    {
        PWIA_PROPERTY_INFO_DATA pInfo = NULL;

        //
        // when a property is being added, always remove any existing property that has the same
        // property ID.  Any call to AddProperty() means that the property being added should be
        // treated as the lastest.
        //

        RemovePropertyAndDeleteData(lPropertyID);

        //
        // allocate a property info structure
        //

        pInfo = AllocatePropertyData();
        if(pInfo)
        {

            //
            // populate the data in the structure, and add it to the property list
            //

            pInfo->szName                      = szName;
            pInfo->pid                         = lPropertyID;
            pInfo->pv.lVal                     = lCurrValue;
            pInfo->pv.vt                       = VT_I4;
            pInfo->ps.ulKind                   = PRSPEC_PROPID;
            pInfo->ps.propid                   = pInfo->pid;
            pInfo->wpi.lAccessFlags            = lAccessFlags;
            pInfo->wpi.vt                      = pInfo->pv.vt;
            pInfo->wpi.ValidVal.Flag.Nom       = lCurrValue;
            pInfo->wpi.ValidVal.Flag.ValidBits = lValidBits;
            m_List.Append(pInfo);
            hr = S_OK;
        }
        else
        {
            hr = E_OUTOFMEMORY;
        }
    }
    return hr;
}

/*****************************************************************************
   Function Name: AddProperty

   Arguments:

   LONG lPropertyID  - Property ID
   LPOLESTR szName   - Property NAME
   LONG lAccessFlags - Property Access Flags
   LONG lCurrValue   - Current Property Value
   LONG lNomValue    - Property Nominal Value
   LONG lMinValue    - Property Minimum Value
   LONG lMaxValue    - Property Maximum Value
   LONG lInc         - Property Increment Value

   Description:

   This function adds a new property to the property list.

   Remarks:
   If a property exists with the same property ID:
        1. The old property is removed from the list, and the contents
           destroyed
        2. The new property is added to the list.

 *****************************************************************************/


HRESULT CWIAPropertyManager::AddProperty(LONG lPropertyID,  
                                         __in LPOLESTR szName, 
                                         LONG lAccessFlags, 
                                         LONG lCurrValue,
                                         LONG lNomValue,
                                         LONG lMinValue,
                                         LONG lMaxValue,
                                         LONG lInc)
{

    HRESULT hr = E_INVALIDARG;
    if((szName)&&
       (lMinValue  <  lMaxValue) &&
       (lNomValue  >= lMinValue) &&
       (lNomValue  <= lMaxValue) &&
       (lCurrValue >= lMinValue) &&
       (lCurrValue <= lMaxValue))  // TODO: validate lInc value???
    {
        PWIA_PROPERTY_INFO_DATA pInfo = NULL;

        //
        // when a property is being added, always remove any existing property that has the same
        // property ID.  Any call to AddProperty() means that the property being added should be
        // treated as the lastest.
        //

        RemovePropertyAndDeleteData(lPropertyID);

        //
        // allocate a property info structure
        //

        pInfo = AllocatePropertyData();
        if(pInfo)
        {

            //
            // populate the data in the structure, and add it to the property list
            //

            pInfo->szName                 = szName;
            pInfo->pid                    = lPropertyID;
            pInfo->pv.lVal                = lCurrValue;
            pInfo->pv.vt                  = VT_I4;
            pInfo->ps.ulKind              = PRSPEC_PROPID;
            pInfo->ps.propid              = pInfo->pid;
            pInfo->wpi.lAccessFlags       = lAccessFlags;
            pInfo->wpi.vt                 = pInfo->pv.vt;
            pInfo->wpi.ValidVal.Range.Inc = lInc;
            pInfo->wpi.ValidVal.Range.Min = lMinValue;
            pInfo->wpi.ValidVal.Range.Max = lMaxValue;
            pInfo->wpi.ValidVal.Range.Nom = lNomValue;
            m_List.Append(pInfo);
            hr = S_OK;
        }
        else
        {
            hr = E_OUTOFMEMORY;
        }
    }
    return hr;
}

/*****************************************************************************
   Function Name: AddProperty

   Arguments:

   LONG lPropertyID  - Property ID
   LPOLESTR szName   - Property NAME
   LONG lAccessFlags - Property Access Flags
   LONG lCurrValue   - Current Property Value
   LONG lNomValue    - Property Nominal Value
   CBasicDynamicArray<LONG> - LONG Array

   Description:

   This function adds a new property to the property list.

   Remarks:
   If a property exists with the same property ID:
        1. The old property is removed from the list, and the contents
           destroyed
        2. The new property is added to the list.

 *****************************************************************************/

HRESULT CWIAPropertyManager::AddProperty(LONG lPropertyID, __in LPOLESTR szName, LONG lAccessFlags, LONG lCurrValue,
                                         LONG lNomValue, __in CBasicDynamicArray<LONG> *pValueList)
{

    HRESULT hr = E_INVALIDARG;
    if((szName)&&(pValueList)&&(pValueList->Size()))
    {
        PWIA_PROPERTY_INFO_DATA pInfo = NULL;
        LONG *pLongList = NULL;

        //
        // when a property is being added, always remove any existing property that has the same
        // property ID.  Any call to AddProperty() means that the property being added should be
        // treated as the lastest.
        //

        RemovePropertyAndDeleteData(lPropertyID);

        if(pValueList)
        {
            LONG lNumValues = (LONG)pValueList->Size();
            if(lNumValues)
            {
                pLongList = (LONG*)LocalAlloc(LPTR,(sizeof(LONG)*lNumValues));
                if(pLongList)
                {
                    for(INT iIndex = 0; iIndex < pValueList->Size(); iIndex++)
                    {
                        pLongList[iIndex] = ((*pValueList)[iIndex]);
                    }
                    hr = S_OK;
                }
                else
                {
                    hr = E_OUTOFMEMORY;
                }

                if(SUCCEEDED(hr))
                {

                    //
                    // allocate a property info structure
                    //

                    pInfo = AllocatePropertyData();
                    if(pInfo)
                    {

                        //
                        // populate the data in the structure, and add it to the property list
                        //

                        pInfo->szName                     = szName;
                        pInfo->pid                        = lPropertyID;
                        pInfo->pv.lVal                    = lCurrValue;
                        pInfo->pv.vt                      = VT_I4;
                        pInfo->ps.ulKind                  = PRSPEC_PROPID;
                        pInfo->ps.propid                  = pInfo->pid;
                        pInfo->wpi.lAccessFlags           = lAccessFlags;
                        pInfo->wpi.vt                     = pInfo->pv.vt;
                        pInfo->wpi.ValidVal.List.pList    = (BYTE*)pLongList;
                        pInfo->wpi.ValidVal.List.Nom      = lNomValue;
                        pInfo->wpi.ValidVal.List.cNumList = lNumValues;
                        m_List.Append(pInfo);
                        hr = S_OK;
                    }
                    else
                    {
                        hr = E_OUTOFMEMORY;
                    }
                }
            }
            else
            {
                hr = E_INVALIDARG;
            }
        }
        else
        {
            hr = E_INVALIDARG;
        }

        if(FAILED(hr))
        {
            if(pLongList)
            {
                LocalFree(pLongList);
                pLongList = NULL;
            }
        }
    }
    return hr;
}

/*****************************************************************************
   Function Name: AddProperty

   Arguments:

   LONG lPropertyID   - Property ID
   LPOLESTR szName    - Property NAME
   LONG lAccessFlags  - Property Access Flags
   BSTR bstrCurrValue - Current Property Value

   Description:

   This function adds a new property to the property list.

   Remarks:
   If a property exists with the same property ID:
        1. The old property is removed from the list, and the contents
           destroyed
        2. The new property is added to the list.

 *****************************************************************************/

HRESULT CWIAPropertyManager::AddProperty(LONG lPropertyID, __in LPOLESTR szName, LONG lAccessFlags, __in BSTR bstrCurrValue)
{

    HRESULT hr = E_INVALIDARG;
    if((szName)&&(bstrCurrValue))
    {
        PWIA_PROPERTY_INFO_DATA pInfo = NULL;

        //
        // when a property is being added, always remove any existing property that has the same
        // property ID.  Any call to AddProperty() means that the property being added should be
        // treated as the lastest.
        //

        RemovePropertyAndDeleteData(lPropertyID);

        //
        // allocate a property info structure
        //

        pInfo = AllocatePropertyData();
        if(pInfo)
        {

            //
            // populate the data in the structure, and add it to the property list
            //

            pInfo->szName                 = szName;
            pInfo->pid                    = lPropertyID;
            pInfo->pv.bstrVal             = SysAllocString(bstrCurrValue);
            pInfo->pv.vt                  = VT_BSTR;
            pInfo->ps.ulKind              = PRSPEC_PROPID;
            pInfo->ps.propid              = pInfo->pid;
            pInfo->wpi.lAccessFlags       = lAccessFlags;
            pInfo->wpi.vt                 = pInfo->pv.vt;
            m_List.Append(pInfo);
            hr = S_OK;
        }
        else
        {
            hr = E_OUTOFMEMORY;
        }
    }
    return hr;
}

/*****************************************************************************
   Function Name: AddProperty

   Arguments:

   LONG lPropertyID   - Property ID
   LPOLESTR szName    - Property NAME
   LONG lAccessFlags  - Property Access Flags
   GUID guidCurrValue - Current Property Value

   Description:

   This function adds a new property to the property list.

   Remarks:
   If a property exists with the same property ID:
        1. The old property is removed from the list, and the contents
           destroyed
        2. The new property is added to the list.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -