OLE字符串2011-04-19冯明德一、概述32位宽字符串,前面32位为长度,尾部以0结束二、相关定义BSTR (又称Basic 类型字符串)LPOLESTR相关宏定义:typedef unsigned short wchar_t; (unsigned short为两字节)
typedef wchar_t WCHAR;
typedef WCHAR OLECHAR; (Win32)
typedef OLECHAR* BSTR;
typedef /* [string] */ OLECHAR __RPC_FAR *LPOLESTR;
三、使用1.分配// Create BSTR containing "Text"
bs = SysAllocString(L"Text")
// Create BSTR containing "Te"
bs = SysAllocStringLen(L"Text", 2)
// Create BSTR containing "Text" followed by and a junk character
bs = SysAllocStringLen(L"Text", 6)
// Reallocate BSTR bs as "NewText" 重新赋值
f = SysReAllocString(&bs, "NewText");
2.长度// Get character length of string.
cch = SysStringLen(bs);
3.释放// Deallocate a string.
SysFreeString(bs);