warning C28717: Invalid VARIANT type
The vt field of a VARIANT struct can take only certain values. Assigning any other value to it is an error.
The vt field of a VARIANT or VARIANTARG struct can only take the following values (possibly ORed by VT_BYREF and/or VT_ARRAY): VT_EMPTY, VT_NULL, VT_I2, VT_I4, VT_R4, VT_R8, VT_CY, VT_DATE, VT_BSTR, VT_DISPATCH, VT_ERROR, VT_BOOL, VT_VARIANT, VT_DECIMAL, VT_RECORD, VT_UNKNOWN, VT_I1, VT_UI1, VT_UI2, VT_UI4, VT_INT, VT_UINT (VT_EMPTY and VT_NULL cannot be combined with VT_ARRAY).
PREfast reports the warning for the following example.
VARIANT var; var.vt = VT_SAFEARRAY | VT_INT;
The following example avoids the error.
VARIANT var; var.vt = VT_ARRAY | VT_INT;