COM: Returning a string from a method
Posted on 2001-07-02
I am writing an ActiveX control for use with Automation.
But now I am stuck (again).
All I simply want to do is to create a string (A BSTR I assume) and return it from my ActiveX method to the caller. How do I do that (the correct way)?
If I allocate memory for the string using SysAllocString() and then return that pointer is it then the responsibility of the caller to deallocate it, or must the callee do that somehow? I would guess that it was the responsibility of the caller since this is the case with AddRef/Release.
PS: I already know all about converting between BSTR/Unicode/ANSI - it is the allocation/deallocation that I am concerned about.
Jacob Marner, B.Sc.