How to pass bool from C # via C ++ com interface to idl

I know that I am missing something simple, I have no experience with these things.

I would like to do this in an interface in idl

[id(5), helpstring("Returns true if the object is in a valid state.")]
HRESULT IsValid([out, retval] boolean bValid);

However, this gives: [out] the parameter is not a pointer.

OK, I get that.

However, in C # code that implements this, I cannot return bool * from the IsValid () method, because it is unsafe.

What is the correct way to return a boolean?

+3
source share
1 answer

Try:

HRESULT IsValid([out, retval] VARIANT_BOOL *bValid);

To work as a result, it must be a pointer to a value; this is how it will be written on the C ++ side:

*bValue = VARIANT_TRUE;

I do not know if you can write a type like boolean- I have ever seen VARIANT_BOOL.

# :

public bool IsValid()

, , (RCW), "" . ++ E_FAIL ( E_WHATEVER), RCW ComException.

[propget], IsValid . , , ( #).

+7

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


All Articles