【发布时间】:2011-09-03 03:12:35
【问题描述】:
对于 C++ COM dll 中的接口,我有一个 out 值作为 BSTR*。我将其返回给 C# .Net 客户端。在我的 C++ 函数中,我必须根据差异条件分配不同的值。
例如:
If my function is fun(BSTR* outval)
{
// I have to assign a default value to it such as:
*outval = SysAllocSTring(L"N");
Then I will check for some DB conditions
{
// And I have to allocate it according to that.
// Do I need to again calling SysAllocString?
eq.*outval = SySAllocString(DBVlaue);
}
}
如果我两次调用 SysAllocSTring 到同一个 BSTR 会发生什么?处理这个问题的最佳方法是什么?
【问题讨论】: