Can anyone explain the difference between the types mentioned above and some sample usage to clearly explain the difference between the two?
Any help would be highly appreciated! Note: this question is a spin-off from this other question
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
BSTRis the string data type used with COM._bstr_tis a wrapper class that works like a smart pointer, so it will free the allocated memory when the variable is destroyed or goes out of scope._bstr_talso has reference counting, which increases every time you pass the_bstr_tvariable by value (avoiding unnecessary copy) and decrement when it is no longer used. Whenever all references are destroyed, the allocated memory for the string is freed.An alternative to
BSTRis theCComBSTR. It also manages the memory for theBSTR, but has no reference counting.