首页 > 解决方案 > 将字符串转换为 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());

  }

最后两行是否正确。不知何故,测试似乎不行!

标签: visual-c++

解决方案


推荐阅读