Maanu
Maanu

Reputation: 5203

COM Method Result is not showing correct value

I have the following method call in my COM component. This method is called from VBScript.

STDMETHODIMP CMyInterface::TestX(VARIANT* myTest)
{
    myTest->vt = VT_I4;
    myTest->lVal = m_nCount;
    ++m_nCount;
    return S_OK;
}

The following code is used to invoke the method. But the last statement ' Response.Write("Value of result" & result)'is not printing 0. What could be the problem?

Set myObject = CreateObject("MyCom.MyInterface")
result=myObject.TestX(value)
Response.Write("Value of result" & result)

Upvotes: 0

Views: 44

Answers (1)

Ciaran Keating
Ciaran Keating

Reputation: 2783

Scripting clients don't consider the HRESULT to be the return value of a method call. Instead, they look for a parameter marked in the IDL as [out, retval] and use that as the return value.

Upvotes: 3

Related Questions