windows 如何获取_bstr_t的长度

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6167301/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 16:57:20  来源:igfitidea点击:

How to get the length of a _bstr_t

c++windowsstring

提问by Lumpi

I am copying a wstring to a _bstr_t using:

我正在使用以下命令将 wstring 复制到 _bstr_t:

_bstr_t name;           
SysFreeString(name);   // Free previous string, if any.
name = SysAllocString(Member[k].Membername);

Now before I use "name" I want to check if it contains at least 5 characters. In other words, I want to check the length of it.

现在在我使用“名称”之前,我想检查它是否至少包含 5 个字符。换句话说,我想检查它的长度。

I didn't find a "countof" or "len" or something like that. Has anyone a idea?

我没有找到“countof”或“len”或类似的东西。有人有想法吗?

Thanks, Lumpi

谢谢,伦皮