Best way to send string into, and receive string back from COM function

I am writing a COM function that will take a string in and return a modified string back. This COM code is written in C++ and will only be used in a C++ environment, meaning is does not need to be used by any other language (VB). My question is, what is the best (easiest to handle) string type to use for this? LPSTR? BSTR? The output string might copy the input string, and then append another string to the output.
BrianDumasAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

jkrCommented:
COM generally uses BSTRs, so it's IMO 'best practices' to use them as well, simply because you will need that string type for interacting with COM helper or initialization functions or other components anyway. '_bstr_t' (https://msdn.microsoft.com/en-us/library/zthfhkd6.aspx) is a great wrapper to make your life easier, and this helper class is almost as versatile as STL strings. But even if you use it just for the conversion from/to BSTRs, they come in handy. BTW, see also http://www.codeproject.com/Articles/4829/Guide-to-BSTR-and-C-String-Conversions ("Guide to BSTR and C String Conversions")
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Karrtik IyerSoftware ArchitectCommented:
If you are developing on Windows 8 or using winrt (windows SDK 8.1) or visual studio 2013 or above, I suggest you use HSTRING.
If you need further help on the same please let me know.
0
Karrtik IyerSoftware ArchitectCommented:
Please refer links below that might help you better understand HSTRING :
https://msdn.microsoft.com/en-us/library/br205775(v=vs.85).aspx
http://www.drdobbs.com/windows/using-c-and-com-with-winrt/240168150
Thanks,
Karrtik
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.