CString(LPCTSTR)转为VARTYPE类型
2011-06-30 22:19
369 查看
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);
}
{
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);
}
相关文章推荐
- 怎样把CString类型转为char数组
- CString LPCTSTR LPTSTR 类型的相互转化
- CString LPCTSTR LPTSTR 类型的相互转化
- 数据类型CString转为string
- vc中各种类型字符串的转换,CString, BSTR, LPCTSTR 概念
- CMap在用CString做key类型时,ARG_KEY要选LPCTSTR
- CString与LPCWSTR、LPSTR、char*、LPWSTR等类型的转换以及CString和LPCTSTR的关系
- CMap在用CString做key类型时,ARG_KEY要选LPCTSTR
- C++ 字符类型总结&CString ,BSTR ,LPCTSTR之间关系和区别
- CString LPCTSTR LPTSTR 类型的相互转化
- LPCTSTR类型理解结合CString加深理解
- LPCTSTR与CString的类型转换
- LPCTSTR、LPTSTR、_T和CString几种类型的区别
- CString类型转为char数组
- MFC把CString类型转为char*型
- C++ 字符类型总结&CString ,BSTR ,LPCTSTR之间关系和区别
- LPCTSTR类型
- Cstring与char、string、int等数据类型的相互转换方法
- Java 如何将List<实体类> 转为List<Object>类型
- CString,BSTR,LPCTSTR之间关系和区别