分类: C/C++
2009-04-18 09:43:52
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_BYREF|VT_UI1 short FAR* piVal; VT_BYREF|VT_I2 long FAR* plVal; VT_BYREF|VT_I4 float FAR* pfltVal; VT_BYREF|VT_R4 double FAR* pdblVal; VT_BYREF|VT_R8 VARIANT_BOOL FAR* pboolVal; VT_BYREF|VT_BOOL SCODE FAR* pscode; VT_BYREF|VT_ERROR CY FAR* pcyVal; VT_BYREF|VT_CY DATE FAR* pdate; VT_BYREF|VT_DATE BSTR FAR* pbstrVal; VT_BYREF|VT_BSTR IUnknown FAR* FAR* ppunkVal; VT_BYREF|VT_UNKNOWN IDispatch FAR* FAR* ppdispVal; VT_BYREF|VT_DISPATCH SAFEARRAY FAR* FAR* pparray; VT_ARRAY|* VARIANT FAR* pvarVal; VT_BYREF|VT_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位 |