VartypeFromString(LPCTSTR lpszType)
{
VARTYPE vtType;
// Compare input type string with supported types and return the
// corresponding variant type. (A match is found when lstrcmpi returns
// zero.) If specified type is not supported, then return VT_EMPTY.
// These strings must match those used below in StringFromVartype().
if (lstrcmpi (lpszType, _T("Boolean")) == 0)
vtType = VT_BOOL;
else if (lstrcmpi (lpszType, _T("Byte")) == 0)
vtType = VT_UI1;
else if (lstrcmpi (lpszType, _T("Byte Array")) == 0)
vtType = VT_UI1 | VT_ARRAY;
else if (lstrcmpi (lpszType, _T("Char")) == 0)
vtType = VT_I1;
else if (lstrcmpi (lpszType, _T("Char Array")) == 0)
vtType = VT_I1 | VT_ARRAY;
else if (lstrcmpi (lpszType, _T("Word")) == 0)
vtType = VT_UI2;
else if (lstrcmpi (lpszType, _T("Word Array")) == 0)
vtType = VT_UI2 | VT_ARRAY;
else if (lstrcmpi (lpszType, _T("Short")) == 0)
vtType = VT_I2;
else if (lstrcmpi (lpszType, _T("Short Array")) == 0)
vtType = VT_I2 | VT_ARRAY;
else if (lstrcmpi (lpszType, _T("DWord")) == 0)
vtType = VT_UI4;
else if (lstrcmpi (lpszType, _T("DWord Array")) == 0)
vtType = VT_UI4 | VT_ARRAY;
else if (lstrcmpi (lpszType, _T("Long")) == 0)
vtType = VT_I4;
else if (lstrcmpi (lpszType, _T("Long Array")) == 0)
vtType = VT_I4 | VT_ARRAY;
else if (lstrcmpi (lpszType, _T("Float")) == 0)
vtType = VT_R4;
else if (lstrcmpi (lpszType, _T("Float Array")) == 0)
vtType = VT_R4 | VT_ARRAY;
else if (lstrcmpi (lpszType, _T("Double")) == 0)
vtType = VT_R8;
else if (lstrcmpi (lpszType, _T("Double Array")) == 0)
vtType = VT_R8 | VT_ARRAY;
else if (lstrcmpi (lpszType, _T("String")) == 0)
vtType = VT_BSTR;
else
vtType = VT_EMPTY;
// Return variant type:
return (vtType);
}