COM interfaces declared in C++ -
usually create com interface 1 should declare in idl file. in project work on have 1 com interface declared in *.h file in c++:
struct declspec_uuid("a67177f7-a4dd-4a80-8ee1-25cf12172068") isomeservice : public iunknown { virtual ~isomeservice() {} virtual hresult initialize(const settings& settings) = 0; // ... }; moreover method initialize takes struct contains std::string fields parameter. corresponding com class implemented in c++ , used c++ module. works fine until run code under appverifier. causes access violation exceptions occur.
so questions are
- is right declare com-interface in *.h file?
- if yes right specify c++ types parameters com interface methods? or should use com compliant types in such cases (bstr etc)?
sure, can describe com interface without using idl. won't able use such idl features type library , marshalling code generation. if using com component in-proc server (dll), , it's ok distribute .h file clients - approach work fine.
avoid using c++ types in interface, because may result in access violations when dealing memory across dll boundaries. better use plain c types, or com types
Comments
Post a Comment