I have a "const char* str" with a very long string. I need to pass it from a cpp client to a .Net COM method which expects BSTR type. Currently I use:
CComBSTR bstr = str;
This has the following issues:
- Sometimes this line fails with out of memory message
- When I pass the bstr to the COM class it takes a lot of memory (much more than the string size) so it can fail with out of memory
Questions:
- Am I converting to CComBSTR wisely? e.g. is there a way to use the heap or something
- Is it better to use BSTR instead?
Any other suggestion is also welcomed...