[prev in list] [next in list] [prev in thread] [next in thread]
List: ms-atl
Subject: [out] parameters
From: Kevin Parkes <Kevin_Parkes () PENOP ! COM>
Date: 1998-02-27 9:03:50
[Download RAW message or body]
I have an object with a number of methods which create and return other
objects.
Some of these methods return the object through an [out,retval] parameter.
In other cases, because I wanted to return an error code on failure, I
tried
to return the object through an [out] parameter and the error code through
the [out,retval] parameter. Here is a simplified example:
interface IMyMainObj : IDispatch
{
...
HRESULT Method1([out,retval] IMyOtherObj * * pObj );
HRESULT Method2([out] IMyOtherObj * * pObj, [out,retval] short *
retval );
...
}
Both methods work fine in VB5. However in VBScript, Method1 works but
trying to call Method2 results in a "Type mismatch" error.
After searching the list archives and other resources, it seems I have two
alternatives:
1. Have Method2 return the object through an [out,retval] and return
something like E_FAIL as the HRESULT on error.
2. Return the object in a Variant, as in:
HRESULT Method2([out] VARIANT * pObj, [out,retval] short * retval );
Am I right? If so, what advantages or disadvantages does each alternative
have? Which would be the prefered alternative?
(By the way, I seem to recall seeing something about using [in,out], rather
than
just [out] for it to work in VB4, is that right?)
Thanks in advance,
Kevin
----------------------------------------------------------------
Users Guide http://www.microsoft.com/sitebuilder/resource/mailfaq.asp
contains important info including how to unsubscribe. Save time, search
the archives at http://microsoft.ease.lsoft.com/archives/index.html
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic