What is the difference between the IDL function attribues propput and propputref? Does it have something to do with marshalling? Can I get a short example?
Posted on 2003-06-29 22:32:20 by Paulicles the Philosopher
propput puts the value.

propputref puts the addresss of where the value is stored.

Same as ByVal and ByRef in VB.
Posted on 2003-06-29 23:59:42 by Ernie
ByRef is implemented behind the scenes using pointers, which is similar to how C++ uses references. However, I can't find the difference between propput and propputref.

For example, ByRef means if you change the value of the parameter passed to the function, the change will be present in the variable the callee used to call the function, because the parameter is a pointer to the location of the callee's variable. ByVal means that the variable is copied, so the called function cannot change the value of the callee's variable.

When propputref, a pointer is not passed. The only parameter in the second declaration below uses a value and not a reference:

// IDL function declarations inside IObjSample, a dual interface...

HRESULT LongProp( LONG* pVal);
HRESULT LongProp( LONG newVal); // Passes parameter by value

Even the C++ ATL implementation uses a value.

// The implemented function
STDMETHODIMP CObjSample::putref_LongProp(LONG newVal)
{
// TODO: Add your implementation code here
myLongProp = newVal;
return S_OK;
}

A reference is not used.
Posted on 2003-06-30 13:27:27 by Paulicles the Philosopher
I think it depends on the data type too.
For example, you can pass say a dword integer value and use ProperyPut, or you could use a PropertyPutRef to do the same thing, using a pointer to the value instead.... but what of a BSTR? You NEVER put a BSTR value in an argument, and you NEVER receive one ... you use pointers to strings here, and so I assume if you used PropertyPutRef, you'd need a pointer to the string pointer (yep, that sounds like C to me)
Posted on 2003-07-10 01:58:31 by Homer