BSTR、LPCOLESTR 等是什么意思? [英] What's the meaning of BSTR, LPCOLESTR, and others?

查看:42
本文介绍了BSTR、LPCOLESTR 等是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果 BSTR、LPCOLESTR、LPCWSTR、LPTSTR、LPCWCHAR 和许多其他的只是一堆解析为 wchar_t 的定义,它们的含义是什么?

What's the meaning of BSTR, LPCOLESTR, LPCWSTR, LPTSTR, LPCWCHAR, and many others if they're all just a bunch of defines that resolve to wchar_t anyway?

推荐答案

LPTSTR 和 LPWSTR 以及类似的定义实际上只是定义.BSTR 和 LPOLESTR 有特殊含义——它们表示指向的字符串是以特殊方式分配的.

LPTSTR and LPWSTR and similar defines are really just defines. BSTR and LPOLESTR have special meanings - they indicate the the string pointed to is allocated in a special way.

BSTR 指向的字符串必须用 SysAllocString() 系列函数分配.LPOLESTR 指向的字符串通常使用 CoTaskMemAlloc() 分配(这应该在文档中查找到接受/返回它的 COM 调用).

String pointed to by BSTR must be allocated with SysAllocString() family functions. String pointed to by LPOLESTR is usually to be allocated with CoTaskMemAlloc() (this should be looked up in the documentation to the COM call accepting/returning it).

如果违反 BSTR 和 LPOLESTR 指向的字符串的分配/解除分配要求,程序可能会遇到未定义的行为.

If allocation/deallocation requirements for strings pointed to by BSTR and LPOLESTR are violated the program can run into undefined behaviour.

这篇关于BSTR、LPCOLESTR 等是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆