C ++ COM: Common Errors

I need to dive into C ++ COM programming again and forget most of the lessons learned from the past. (when I think the phrase "never again" was not used by mistake.)

What are the most common errors and anti-COM development patterns in C ++? I use Borland C ++ Builder, but I am for what applies to all C ++ compilers.

+4
source share
2 answers

My mistake did not read the manual. I just tried using the tutorials and code examples found on the Internet. I spent many hours on problems that would be easy to solve if I got a good basic understanding of COM.

+2
source

I hit the ball, rolling myself first, with which I stumbled again:

Do not pass literal strings to functions that require BSTR parameters. See the comments section here .

CComPtr<IFoo> foo; foo->bar("Bletch!"); // No valid BSTR prefix, so bad things will happen. 

Use ... instead

 foo->bar(CComBSTR("Bletch!")); 
0
source

Source: https://habr.com/ru/post/1347083/


All Articles