I have an out
value as BSTR* for an interface in a C++ COM dll. And I am returning this to a C# .Net client. In my C++ function I have to assign different values according to a diff condition.
For example:
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);
}
}
What happens if I call SysAllocSTring two times to the same BSTR? What is the best way to handle this?