Controlling Powered Vehicle Mechanisms

Vehicle I/O API enables you to write code to control powered vehicle mechanisms, such as door locks and windows.

    To control powered vehicle mechanisms with code

  1. Obtain a reference to the mechanism’s IVioDevice interface.
  2. Set the state of the device using the interface’s SetData method.
  3. Release the reference to the mechanism’s IVioDevice interface.

The following code example shows how to control vehicle door locks.

IVIO_Device     *pDevice;
VARIANT         vLockState;

// Create a lock state IVIO_Device.
hr = CoCreateInstance(CLSID_VIO_LOCK_STATE, NULL, CLSCTX_INPROC_SERVER,
                      IID_VIODEVICE, (PVOID *) &pDevice);
VariantInit(&vLockState);
// Set the state of the locks to toggle.
V_UI4(&vLockState) = VIOLOCK_TOGGLE;
// Call the vehicle I/O API to toggle the power lock.
hr = pDevice->SetData(&vLockState, 2000);
// Free the resources of the VARIANT.
VariantClear(&vLockState);
// Release the reference to the device.
pDevice->Release();