Obtaining Vehicle Attributes

The IVIO_EnumMetrics interface, which you obtain from a IVIO_Vehicle interface, enumerates vehicle attributes, such as manufacturer, model number, number of cylinders, and transmission type. The following code example shows how to create an instance of a vehicle interface and how to get an enumeration interface from the vehicle interface. You then use IVIO_DataValue methods to obtain vehicle attributes.

IVIO_Vehicle            *pVehicle;
IVIO_EnumMetrics        *pVehicleMetrics;
IVIO_DataValue        *pDataValue[1];
VARIANT                vAttributeValue;

// Create an instance of an IVIO_Vehicle interface.
hr = CoCreateInstance (CLSID_VIOVEHICLE, NULL, CLSCTX_INPROC_SERVER,
                       IID_VIOVEHICLE, (PVOID *) &pVehicle);
// Retrieve a IVIO_EnumMetrics interface from the IVIO_Vehicle interface.
hrMetrics = pVehicle->get_Metrics (&pVehicleMetrics);
VariantInt(&vAttributeValue);
// Get the first element of the metrics list. This may be a loop to 
// access all attributes.
hrMetrics = pVehicleMetrics->Next(1, pDataValue, NULL);
if (hrMetrics == S_OK)
  {
  // Read the next vehicle attribute.
  pDataValue[0]->get_ItemID(&dwAttributeID);
  // Copy the attribute data.
  pDataValue[0]->get_DataValue(&vAttributeValue);

  // Process the attribute.

  // Release the reference that was returned.
  pDataValue[0]->Release();
  }
// Clear the VARIANT buffer.
VariantClear(&vAttributeValue);
// Release the metrics enumerator.
pVehicleMetrics->Release;