This CLSID returns the current battery output voltage.
Battery voltage
Read, shareable or exclusive
Type: | VT_UI2 (unsigned short fixed point decimal) |
Low: | 0.00 |
High: | 32.77 |
None
Type: | VT_UI2 (unsigned short fixed point decimal) |
Measurement: | VIOMEASUREMENT_VOLTAGE |
Units: | VIOUNITS_VOLTS |
API device objects expect the following data types and sizes when sending data to and from the mini-drivers:
None
Type: | SHORT * |
Size: | 2 bytes |
Description: | Battery voltage in 0.001 volt increments. |
HRESULT hr;
IVIO_Device *pBatteryVoltage;
VIODEVICEMETRICS dmBattery;
VARIANT vDeviceData;
USHORT usFixedPointVoltage;
float fFloatVoltage;
//Create an instance of the battery voltage device and get its
//IVIO_Device interface.
hr = CoCreateInstance(CLSID_VIO_BATTERY_VOLTAGE, NULL,
CLSCTX_INPROC_SERVER, IID_VIODEVICE,
&pBatteryVoltage);
//Get the metrics for the battery voltage device.
pBatteryVoltage->get_Metrics(&dmBattery);
//Ask the device for current voltage.
pBatteryVoltage->GetData(&vDeviceData, 3000);
//Fetch the battery voltage as a fixed-point value from the VARIANT.
usVoltage = vDeviceData.uiVal;
//Convert the fixed-point value to a float value.
fFloatVoltage = ((float) usVoltage) * (10 ^ dmBattery.lExponent);
//Release the reference to the interface.
pBatteryVoltage->Release();