A BSTR
is dynamically allocated by SysAllocString
(if I recall the name correctly, check it!).
There is a corresponding deallocation function.
Just read the documentation.
If you're using the Visual C++ compiler, and don't plan on ever porting the code to other compilers, then you can use the "smart BSTR" class bundled with Visual C++. I can't exactly recall the name. But something like _bstr_t
. Wait, checking the docs... OK, typing "_bstr" in the index supplied the name, it is _bstr_t
as I thought! :-)
With use of the "smart" class it handles deallocation for you.