Hi,
I've made a COM server in C++ and now I've some problems when using it
in LabView. It is working fine in C++, VB and Delphi, but not in
LabView. The problem occurs when I return a VARIANT of type VT_BYREF.
It seems like LabView can't handle that, I get an error message when
Func1 returns saying "Bad variable type" (-2147352568).
In my COM server I have:
class A
{
};
Then I return a pointer to this class, and do that by casting it to a
void pointer and store it in a VARIANT of type VT_BYREF.
STDMETHODIMP COMClass::Func1(/*out*/VARIANT *pHandle)
{
A *pA = new A;
//Fill A with stuff
VariantInit(pHandle);
pHandle->vt = VT_BYREF;
pHandle->byref = (void *)pA;
return S_OK;
}
I've tried to remove the line "pHandle->vt = VT_BYREF;"
, and then the
function succeeds, but the next function fails.
STDMETHODIMP COMClass::Func2(/*in*/VARIANT *pHandle)
{
if(pHandle)
{
if(!pHandle.byref)
AfxMessageBox("byref empty!");
// The message box appears and another control shows that
pHandle.vt == 0.
}
}
How can I pass a void * in COM so LabView can handle it? The user
isn't supposed to do anything with the pointer just pass it back to
the next function.
Thanks,
/Therese