I have a method defined in IDL as follows:
interface IMyFunc : IDispatch
{
[id(1), helpstring("method GetNextFunction")] HRESULT GetNextFunction(
[in,out] long* lPos, [out, retval] BSTR* bstrName);
}
Using C ++, I always did this as follows:
STDMETHODIMP CMyFunc::GetNextFunction(long *nID, long *lPos, BSTR *bstrName)
{
if ( function to return )
{
return S_OK;
}
else
{
return S_FALSE;
}
}
Now I implement this in C # and used tlbimp in the type library and ended up with:
public string GetNextFunction(ref int nID, ref int lPos)
I understand that this is because [out, retval] is used as the return type instead of HRESULT, as in C ++. Is there an easy way to return S_OK / S_FALSE values without changing the method definition? The only way I see is that I have to use ildasm / ilasm to add saveesig so that it ends up with something like this:
public int GetNextFunction(ref int nID, ref int lPos, ref string bstrName)
I was wondering if there is another way without performing the il compilation step.
source
share