ILogicalSensorManager::Connect method
[ILogicalSensorManager::Connect is no longer available for use as of Windows 8.]
Connects to a logical sensor.
Syntax
HRESULT Connect( [in] REFGUID logicalID, [in] IPropertyStore *pPropertyStore );
Parameters
- logicalID [in]
-
REFGUID that identifies the logical sensor instance.
- pPropertyStore [in]
-
Pointer to the IPropertyStore interface used to transfer data to the driver instance.
The property store can contain one or more of the following values.
Return value
The method returns an HRESULT. Possible values include, but are not limited to, those in the following table.
| Return code | Description |
|---|---|
|
The method succeeded. |
|
No permission. Connecting a logical sensor requires administrator privileges. If you receive this error while debugging, restart the development environment as administrator. |
|
The specified logical sensor is already connected. |
Remarks
This method installs the specified logical sensor, if needed. If the logical sensor device node already exists, this method simply creates a connection to make the logical sensor available to the Sensor and Location Platform.
Examples
The following example code creates a helper method that connects to a specified logical sensor. The method parameters receive the sensor hardware ID and a unique GUID to identify the sensor.
HRESULT ConnectToLogicalSensor(PCWSTR* wszHardwareID, GUID guidLogicalID)
{
HRESULT hr = S_OK;
ILogicalSensorManager* pLSM = NULL;
IPropertyStore* pStore = NULL;
PROPVARIANT pv = {};
// Create the property store.
hr = PSCreateMemoryPropertyStore(IID_PPV_ARGS(&pStore));
if(SUCCEEDED(hr))
{
// Create the logical sensor manager.
hr = CoCreateInstance(CLSID_LogicalSensorManager,
NULL,
CLSCTX_INPROC_SERVER,
IID_PPV_ARGS(&pLSM));
}
// Fill in the values.
if(SUCCEEDED(hr))
{
hr = InitPropVariantFromStringVector(wszHardwareID, 1, &pv);
}
if(SUCCEEDED(hr))
{
hr = pStore->SetValue(PKEY_Device_HardwareIds, pv);
}
if(SUCCEEDED(hr))
{
hr = pStore->SetValue(PKEY_Device_CompatibleIds, pv);
}
if(SUCCEEDED(hr))
{
// Connect to the logical sensor.
hr = pLSM->Connect(guidLogicalID, pStore);
}
SafeRelease(&pStore);
SafeRelease(&pLSM);
return hr;
}
Requirements
|
Minimum supported client | Windows 7 [desktop apps only] |
|---|---|
|
Minimum supported server | None supported [desktop apps only] |
|
End of client support | Windows 7 |
|
Header |
|
|
Library |
|
|
DLL |
|
See also
Build date: 11/19/2012