Reputation: 11399
I have a function that expects a short*
as an argument.
I would need to convert this to a VARIANT_BOOL*
.
Can anybody tell me a reliable way to do this?
I can even pass the VARIANT_BOOL*
to the function, but then the VARIANT_BOOL*
is not filled with the correct value.
Thank you very much for the help!
STDMETHODIMP CWrapper::get_IsOpen(VARIANT_BOOL* uIsOpen, LONG* pVal)
{
if (_c)
{
*pVal=_c->IsOpen(uIsOpen); //_c->IsOpen expects short* as argument
return S_OK;
}
else
{
return S_FALSE;
}
}
Upvotes: 0
Views: 235
Reputation: 110728
VARIANT_BOOL
is defined as:
typedef short VARIANT_BOOL;
So if you want to pass a VARIANT_BOOL
to a function that takes a short*
, you need to take its address using &
. If you want turn the short
that a short*
points at into a VARIANT_BOOL
, you need to perform indirection using *
.
VARIANT_BOOL vb = VARIANT_TRUE;
short* sp = &vb; // VARIANT_BOOL to short*
VARIANT_BOOL vb2 = *sp; // short8 to VARIANT_BOOL
Upvotes: 3
Reputation: 1101
Put the VARIANT_BOOL in a short, call the function, put the short back into the VARIANT_BOOL.
Upvotes: 0