I'm implementing COM automation (dual interface) for an application. The automation interface will be called from VBScript. I'm not quite clear on what types are allowed for the method's arguments. I do know that basically values have to fit in a VARIANT, but does that mean every parameter of type int must be passed through a VARIANT, or can one pass int directly?
For example, two methods I have in my MIDL file are:
HRESULT SetDate([in] int Year, [in] int Month, [in] int Day);
HRESULT GetDate([out] int* pYear, [out] int* pMonth, [out] int* pDay);
Calling SetDate from VBScript works. Calling GetDate as shown fails, which is to say that in the implementation, which is in C++, ITypeInfo::Invoke returns a code indicating a type error.
I've observed that if I use a VARIANT instead of an int, as shown below, it works.
HRESULT GetDate([out] VARIANT* pYear, [out] VARIANT* pMonth, [out] VARIANT* pDay);
So is int not allowed for parameters (because of the dual interface), or must I be doing something else wrong? If int is not allowed, why does SetDate work - is there a difference between in and out parameters in this respect?
Furthermore, this pair of methods works, although both use int:
[propget] HRESULT System([out, retval] int* pSystem);
[propput] HRESULT System([in] int System);
How come - are the rules for the allowed parameter types different for a property, or when the parameter is declared as retval?
I can't quite make sense of it all - would be grateful if anyone can clarify this.