Esempio n. 1
0
HRESULT BthLEDevice::GetObjectIDsByFormat(
            ACCESS_SCOPE                          Scope,
            REFGUID                               guidObjectFormat,
    _In_    LPCWSTR                               wszParentObjectID,
            const DWORD                           dwDepth,
    _Inout_ IPortableDevicePropVariantCollection* pObjectIDs)
{
    HRESULT      hr       = S_OK;
    AbstractDeviceContent* pContent = NULL;

    if(pObjectIDs == NULL)
    {
        hr = E_POINTER;
        CHECK_HR(hr, ("Cannot have NULL parameter"));
        return hr;
    }

    hr = GetContent(Scope, wszParentObjectID, &pContent);
    CHECK_HR(hr, "Failed to get content '%ws'", wszParentObjectID);

    if (hr == S_OK)
    {
        hr = pContent->GetObjectIDsByFormat(Scope, guidObjectFormat, dwDepth, pObjectIDs);
        CHECK_HR(hr, "Failed to get object IDs by format");
    }

    return hr;
}
Esempio n. 2
0
HRESULT AbstractDeviceContent::GetObjectIDsByFormat(
            ACCESS_SCOPE                          Scope,
            REFGUID                               guidFormat,
            const DWORD                           dwDepth,
    _Inout_ IPortableDevicePropVariantCollection* pObjectIDs)
{
    HRESULT hr = S_OK;    

    CComCritSecLock<CComAutoCriticalSection> Lock(m_ChildrenCS);

    if (CanAccess(Scope))
    {
        DWORD        dwIndex = 0;
        AbstractDeviceContent* pChild  = NULL;

        if (Format == guidFormat || guidFormat == WPD_OBJECT_FORMAT_ALL)
        {
            PROPVARIANT pv = {0};
            PropVariantInit(&pv);
            pv.vt = VT_LPWSTR;
            pv.pwszVal = ObjectID.GetBuffer();
            hr = pObjectIDs->Add(&pv);               
            CHECK_HR(hr, "Failed to add '%ws' to the list of object IDs by format", ObjectID);           
        }

        if (dwDepth > 0)
        {
            while ((hr == S_OK) && (FindNext(Scope, dwIndex, &pChild)))
            {            
                hr = pChild->GetObjectIDsByFormat(Scope, guidFormat, dwDepth-1, pObjectIDs);
                CHECK_HR(hr, "Failed to get object IDs by format for child at index %d", dwIndex);
                dwIndex++;
            }
        }
    }
    else
    {
        hr = E_ACCESSDENIED;
    }
    
    return hr;
}