visual-c++ - 将字符串转换为 BSTR
问题描述
从以下函数中,我使用路径。现在我生成一些让我们说由换行符分隔的名称列表
func(BSTR * path)
{
// From path paramter client sent, I use the path.
//Now I generate some lets say list of names separated by newline
string output = "Bob\n Rob \n Lilly \n";
// Now client wants the path to be modified with the output
// So i did the following
SysFreeString(*path);
*path= SysAllocStringByteLen(output.c_str(), output.size());
}
最后两行是否正确。不知何故,测试似乎不行!
解决方案
推荐阅读
- flutter - 如何在颤动中仅读取音乐的特定文件夹?
- sql - Hive SQL 排名与关系
- swift - 如何将默认蓝色注释用于用户位置而不是我的自定义注释?
- javascript - Node.js - 有没有办法通过索引读取存储中的数组?
- c - 从用户那里获取密码
- database - 如果在 prestashop 1.6 中成功连接后与 DB 通信时出现任何问题,则记录数据库连接
- numpy - 为什么 np.dot 会产生我刚刚从书中复制的属性错误?
- python - 增加matplotlib中图像的显示尺寸
- android - 使用 getDefaultSharedPreferences,遇到 Context 问题
- django - 如何从表 def __str__(self) 打印多个对象:返回 self.title