BSTRs are wide, double-byte (Unicode) strings on 32-bit Windows platforms and narrow, single-byte strings on the Apple® PowerMac™. BSTR只能用SysAllocString/SysFreeString来管理, wchar_t* 可以通过new/delete来管理。 http://msdn.microsoft.com/library/default.asp?url=/library/en-us/automat/htm/chap7_5alv.asp BSTR本身保存有string的长度:The length is stored as a 32-bit integer at the memory location preceding the data in the string.
还有一个问题: TCHAR szBuffer[512]; wsprintf(szBuffer,_T("errord")); SysAllocString(szBuffer); 最后一行编译通不过. error C2664: 'SysAllocString' : cannot convert parameter 1 from 'char [512]' to 'const unsigned short *'
CHAR是字符,以上每一个都是一个CHAR
WCHAR是Wide CHAR就是宽字符,顾名思义,2个CHAR空间保存的字符的Unicode编码。这个编码 没法举例了。不记得~
BSTR只能用SysAllocString/SysFreeString来管理,
wchar_t* 可以通过new/delete来管理。
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/automat/htm/chap7_5alv.asp
BSTR本身保存有string的长度:The length is stored as a 32-bit integer at the memory location preceding the data in the string.
TCHAR szBuffer[512];
wsprintf(szBuffer,_T("errord"));
SysAllocString(szBuffer);
最后一行编译通不过.
error C2664: 'SysAllocString' : cannot convert parameter 1 from 'char [512]' to 'const unsigned short *'