IAutomation - How retrieve value of argument which passed by pointer?
In .idl file writed:
interface IAutomation : IDispatch {
[id(0x000000e0), helpstring("Returns if the player is ready. Many of the other commands fail as long as the player is not ready.")]
HRESULT GetReady([out] VARIANT* Ready);
};
I suppose, GetReady() - method, not property.
If I trying use VOLE library:
object player = object::create("StereoPlayer.Automation", CLSCTX_LOCAL_SERVER, vole::coercion_level::valueCoercion);
VARIANT var;
::VariantInit(&var);
VARIANT pos = player.invoke_method(vole::of_type<VARIANT>(), L"GetReady", var);
But recieve linker error:
error LNK2019: unresolved external symbol "public: static struct tagVARIANT __cdecl vole::com_return_traits<struct tagVARIANT>::convert(struct tagVARIANT const &,enum vole::coercion_level::coercion_level)" (?convert@?$com_return_traits@UtagVARIANT@@@vole@@SA?AUtagVARIANT@@ABU3@W4coercion_level@42@@Z) referenced in function "public: struct tagVARIANT __thiscall vole::object::invoke_method<struct tagVARIANT,struct tagVARIANT>(struct vole::of_type<struct tagVARIANT>,unsigned short const *,struct tagVARIANT const &)" (??$invoke_method@UtagVARIANT@@U1@@object@vole@@QAE?AUtagVARIANT@@U?$of_type@UtagVARIANT@@@1@PBGABU2@@Z)
Calling other methods, which return nothing, works perfectly.
Also I try directly call method IDispatch::Invoke() as discribed in How To Use Visual C++ to Access DocumentProperties with Automation . But misunderstood how return value too.
I am not familiar with VOLE, but if I am reading its source code correctly, you need to do this instead:
VARIANT pos = player.invoke_method<VARIANT>(L"GetReady");
Or this:
VARIANT pos = player.invoke_method(vole::of_type<VARIANT>(), L"GetReady");
You are trying to pass in a VARIANT
as an [in]
parameter to GetReady()
, but it has no such parameter. It has an [out]
parameter instead, which is represented by the return value of invoke_method()
, so you don't need to pass in your own VARIANT
parameter.
invoke_method()
performs VARIANT
-to-type coersions internally, so assuming GetReady()
actually returns a boolean value wrapped in a VARIANT
, you might even be able to do something like this:
VARIANT_BOOL ready = player.invoke_method<VARIANT_BOOL>(L"GetReady");
Or even:
bool ready = player.invoke_method<bool>(L"GetReady");
User contributions licensed under CC BY-SA 3.0