int i = 100;
long l = 2001;
float f=300.2;
double d=12345.119;
char username[]="女侠程佩君";
char temp[200];
char *buf;
CString str;
_variant_t v1;
_bstr_t v2;
itoa(i,temp,10);///将i转换为字符串放入temp中,最后一个数字表示十进制
itoa(i,temp,2); ///按二进制方式转换
ltoa(l,temp,10);
str = "2008北京奥运";
buf = (LPSTR)(LPCTSTR)str;
v1 = (_bstr_t)"程序员";
buf = _com_util::ConvertBSTRToString((_bstr_t)v1);
strcpy(temp,"123");
i = atoi(temp);
l = atol(temp);
d = atof(temp);
str.Format("%d",i);
str.Format("%f",i);
str = username;
char *p=_com_util::ConvertBSTRToString(b);
VARIANT va;
int a=2001;
va.vt=VT_I4;///指明整型数据
va.lVal=a; ///赋值
unsigned char bVal; VT_UI1
short iVal; VT_I2
long lVal; VT_I4
float fltVal; VT_R4
double dblVal; VT_R8
VARIANT_BOOL boolVal; VT_BOOL
SCODE scode; VT_ERROR
CY cyVal; VT_CY
DATE date; VT_DATE
BSTR bstrVal; VT_BSTR
IUnknown FAR* punkVal; VT_UNKNOWN
IDispatch FAR* pdispVal; VT_DISPATCH
SAFEARRAY FAR* parray; VT_ARRAY*
unsigned char FAR* pbVal; VT_BYREFVT_UI1
short FAR* piVal; VT_BYREFVT_I2
long FAR* plVal; VT_BYREFVT_I4
float FAR* pfltVal; VT_BYREFVT_R4
double FAR* pdblVal; VT_BYREFVT_R8
VARIANT_BOOL FAR* pboolVal; VT_BYREFVT_BOOL
SCODE FAR* pscode; VT_BYREFVT_ERROR
CY FAR* pcyVal; VT_BYREFVT_CY
DATE FAR* pdate; VT_BYREFVT_DATE
BSTR FAR* pbstrVal; VT_BYREFVT_BSTR
IUnknown FAR* FAR* ppunkVal; VT_BYREFVT_UNKNOWN
IDispatch FAR* FAR* ppdispVal; VT_BYREFVT_DISPATCH
SAFEARRAY FAR* FAR* pparray; VT_ARRAY*
VARIANT FAR* pvarVal; VT_BYREFVT_VARIANT
void FAR* byref; VT_BYREF
long l=222;
ing i=100;
_variant_t lVal(l);
lVal = (long)i;
COleVariant v3 = "字符串", v4 = (long)1999;
CString str =(BSTR)v3.pbstrVal;
long i = v4.lVal;
LPARAM lParam;
WORD loValue = LOWORD(lParam);///取低16位
WORD hiValue = HIWORD(lParam);///取高16位
WORD wValue;
BYTE loValue = LOBYTE(wValue);///取低8位
BYTE hiValue = HIBYTE(wValue);///取高8位
更多内容请看C/C++技术专题专题,或新闻热点
疑难解答