Applications can share vehicle data or jointly control vehicle mechanisms. For example, multiple applications may use vehicle speed data or control door locks. Multiple applications can also restrict control over, or access to, vehicle mechanisms.
The following code example shows how to maintain exclusive control of vehicle door locks until a specific process is performed. Once the process is performed, the access mode must be reset to shared so that other applications can access the mechanism.
IVIO_Device *pDevice;
// Create a door lock IVIO_Device interface.
hr = CoCreateInstance(CLSID_VIO_DOOR_LOCKS, NULL, CLSCTX_INPROC_SERVER,
IID_VIODEVICE, (PVOID *) &pDevice);
// Set the read access mode to exclusive.
pDevice->set_AccessMode(VIODEVICEMODE_READ, VIODEVACCESS_EXCLUSIVE);
// You can perform any operations on the device that require exclusive
// access now. When done, reset the device access mode to shared access.
pDevice->set_AccessMode(VIODEVICEMODE_READ, VIODEVACCESS_SHARED);
// Release the reference to the device.
pDevice->Release();