tags:

views:

21

answers:

2

One of my COM interface methods needs a parameter of user defined type as below:

[uuid(58ADDA77-274B-4B2D-B8A6-CAB5A3907AE7), object]    //Interface
interface IRadio : IUnknown
{
        ...
    HRESULT test_method2(someUDT* p2p_UDT);
        ...
};

How could fit the definition of the someUDT in the *.idl file? The someUDT type is a user defined struct.

Thanks.

A: 

I think that you need to define the struct in the idl file. Something like:

[
    uuid("..."),
    v1_enum,
    helpstring("Enum")
]
typedef enum MyEnum {
    value_a,
    value_b,
    value_c
} MyEnum_t;
Adrian Faciu
I am trying it. But no success for now. Could you give some example about a struct? thanks.
smwikipedia
I tried with my struct but the following warning appeared: warning MIDL2368: error generating type library, ignored : Could not set UUID : _someUDT (0x800288C6)
smwikipedia
Thanks Adrian. Problem solved. :)
smwikipedia
A: 

Perhaps this helps you - it's german but the most interesting part is the code.

This is how a Struct is defined there:

[ 
    uuid(62D33614-1860-11d3-9954-10C0D6000000), 
    version(1.0) 
] 
typedef struct TPerson 
{ 
    BSTR bstrFirstname; 
    BSTR bstrLastname; 
    long lAge; 
    TDepartment Dep; 
} TPerson; 
// Interface 

This is how it is used later:

[ 
    object, 
    uuid(FC126BCD-1EAC-11D3-996A-4C1671000000), 
    dual, 
    helpstring("ICMyUDT Interface"), 
    pointer_default(unique) 
] 
interface ICMyUDT : IDispatch 
{ 
    [id(1), helpstring("method PassUdtByRef")] HRESULT  
        PassUdtByRef([ref, in, out] TPerson* pPerson); 
    [id(2), helpstring("method ReturnUdt")] HRESULT ReturnUdt( 
        [out, retval] TPerson* pPerson); 
    [id(3), helpstring("method PassUdtByVal")] HRESULT  
        PassUdtByVal([in] VARIANT varPerson); 
}; 
David Feurle
Many thanks, David. :)
smwikipedia