一、概述
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 \0 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);
时间: 2024-11-01 01:46:27