Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

ISensorManager::GetSensorsByType method

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

Syntax


HRESULT GetSensorsByType(
  [in]   REFSENSOR_TYPE_ID sensorType,
  [out]  ISensorCollection **ppSensorsFound
);

Parameters

sensorType [in]

ID of the type of sensors to retrieve.

ppSensorsFound [out]

Address of an ISensorCollection interface pointer that receives the 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
S_OK

The method succeeded.

HRESULT_FROM_WIN32(ERROR_NOT_FOUND)

No sensors are available for the specified type.

E_POINTER

NULL was passed in for ppSensorsFound.

 

Examples

The following example code retrieves a collection of sensors of the type named SAMPLE_SENSOR_TYPE_TIME. The code then retrieves the first sensor in the collection by its index.


// Get the sensor collection.
hr = pSensorManager->GetSensorsByType(SAMPLE_SENSOR_TYPE_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 type.\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

Show:
© 2014 Microsoft