Usually to create COM interface one should declare it in IDL file. In the project I work on I have one 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 the method Initialize takes a struct that contains std::string fields as its parameter. The corresponding COM class is implemented in C++ and it is used from another C++ module. This works fine until I run the code under AppVerifier. It causes access violation exceptions to occur.
So my questions are
- Is it right to sometimes declare COM-interface in *.h file?
- If yes is it right to specify C++ types as parameters for COM interface methods? Or should I always use COM compliant types in such cases (BSTR etc)?