Export (0) Print
Expand All

ISensorManager::GetSensorsByCategory method

Retrieves a collection containing all sensors associated with the specified category.

Syntax


HRESULT GetSensorsByCategory(
  [in]   REFSENSOR_CATEGORY_ID sensorCategory,
  [out]  ISensorCollection **ppSensorsFound
);

Parameters

sensorCategory [in]

ID of the sensor category to retrieve.

ppSensorsFound [out]

Address of an ISensorCollection interface pointer that receives a pointer to the sensor collection requested.

Return value

The method returns an HRESULT. Possible values include, but are not limited to, those in the following table.

Return codeDescription
HRESULT_FROM_WIN32(ERROR_NOT_FOUND)

No sensors are available for the specified category.

S_OK

The method succeeded.

E_POINTER

NULL was passed in for ppSensorsFound.

 

Examples

The following example code retrieves a collection of sensors that belong to the category named SAMPLE_SENSOR_CATEGORY_DATE_TIME. The code then retrieves the first sensor in the collection by its index.


// Get the sensor collection.
hr = pSensorManager->GetSensorsByCategory(SAMPLE_SENSOR_CATEGORY_DATE_TIME, &pSensorColl);
  
if(SUCCEEDED(hr))
{
    ULONG ulCount = 0;

    // Verify that the collection contains
    // at least one sensor.
    hr = pSensorColl->GetCount(&ulCount);

    if(SUCCEEDED(hr))
    {
        if(ulCount < 1)
        {
            wprintf_s(L"\nNo sensors of the requested category.\n");
            hr = E_UNEXPECTED;
        }
    }
}

if(SUCCEEDED(hr))
{
    // Get the first available sensor.
    hr = pSensorColl->GetAt(0, &pSensor);
}


Requirements

Minimum supported client

Windows 7 [desktop apps only]

Minimum supported server

None supported

Header

Sensorsapi.h

Library

Sensorsapi.lib

DLL

Sensorsapi.dll

See also

ISensorManager
Retrieving a Sensor Object

 

 

Community Additions

ADD
Show:
© 2014 Microsoft