ISensorClassExtension::PostStateChange method

The ISensorClassExtension::PostStateChange method notifies the sensor class extension about a change in the operational state of the sensor.

Syntax


HRESULT PostStateChange(
  [in]  LPWSTR pwszSensorID,
  [in]  SensorState State
);

Parameters

pwszSensorID [in]

LPWSTR that contains the ID for the sensor for which the driver is raising the event.

State [in]

SensorState value that indicates the new state.

Return value

This method returns an HRESULT. Possible values include, but are not limited to, one of the following values.

Return codeDescription
S_OK

The method succeeded.

E_POINTER

A required pointer argument was NULL.

HRESULT_FROM_WIN32(ERROR_CAN_NOT_COMPLETE)

The class extension is not initialized.

 

Remarks

Sensor state information is also available through the SENSOR_PROPERTY_STATE property key.

Examples

The following example code demonstrates a function that posts a state-changed event.


HRESULT PostStateEvent()
{
    // Validate that we have a pointer to the class extension.
    HRESULT hr = (NULL == m_spSensorCXT) ? E_UNEXPECTED : S_OK ;

    if (SUCCEEDED(hr))
    {
        SensorState st;
 
        // Retrieve the sensor state
        hr = m_pDdi->GetSensorState(&st);

        if (SUCCEEDED(hr))
        {
            // Post the state change event.
            hr = m_spSensorCXT->PostStateChange(g_wszSensorID, st);
        }
    }

    return hr;
}

Requirements

Minimum supported client

Windows 7

Minimum supported server

None supported

Version

Available in Windows 7.

Header

Sensorsclassextension.h

Library

SensorsClassExtension.lib

See also

ISensorDriver::OnClientSubscribeToEvents
ISensorDriver::OnClientUnsubscribeFromEvents

 

 

Send comments about this topic to Microsoft

Показ:
© 2014 Microsoft