Reading a GUID Property from COM object with C++Builder

0

I have a 3rd party COM object that I'm working with. Mostly fine, but I'm stuck on reading a GUID property from the object.

The relevant part of the auto-generated component wrappers/headers looks like this:

// *********************************************************************//
// DispIntf:  IFoo
// Flags:     (4416) Dual OleAutomation Dispatchable
// GUID:      {5DE5DAAF-5419-4B2B-9771-58EAEE780799}
// *********************************************************************//
template<class T>
class IFooDispT : public TAutoDriver<IFoo>
{
  ...
BSTR    __fastcall get_FileName(void);
HRESULT __fastcall get_ProjectGUID(/*AUTO_PARAM_ERROR(System::TGUID* Value)*/ VARIANT*  Value);
HRESULT __fastcall get_ProjectName(BSTR* Value/*[out,retval]*/);

__property   BSTR  FileName = {read = get_FileName};
__property   BSTR  ProjectName = {read = get_ProjectName};

Note how the ProjectGUID property is marked AUTO_PARAM_ERROR, and it doesn't appear in list of properties.

I've tried to read it directly via get_ProjectGUID() but it always returns HRESULT = 0x80070057 (E_INVALID_ARGS).

The IDL of the dispinterface from OleView looks like this:-

[
  uuid(5DE5DAAF-5419-4B2B-9771-58EAEE780799),
  version(1.0),
  helpstring("Dispatch interface for xpCOMFoo Object"),
  dual
]
dispinterface IFoo {
    properties:
    methods:
 <...snipped...>
        [id(0x000000cf), propget]
        BSTR FileName();
        [id(0x000000d0), propget]
        GUID ProjectGUID();
        [id(0x000000d1), propget]
        BSTR ProjectName();
};

I've tested the same object from Delphi (although, not using the late bindings shown above) and I'm happy that the COM object itself is not at fault.

com
c++builder
asked on Stack Overflow Apr 25, 2014 by Roddy • edited Apr 26, 2014 by Roddy

1 Answer

0

Try calling it like this:

TAutoDriver<IFoo> foo;

// ...

GUID guid;
memset(&guid, 0, sizeof(guid));
// use -> to access the raw dual interface
HRESULT hr = foo->get_ProjectGUID(&guid); 
answered on Stack Overflow Apr 27, 2014 by noseratio

User contributions licensed under CC BY-SA 3.0