Re: Passing parameters to a Com DLL
"WishfulDoctor" <WishfulDoctor@discussions.microsoft.com> wrote in
message news:196C90AB-1D35-4D6E-BEE1-C0ED6F51B87F@microsoft.com
I have a Com server dll - dual interface as I really need to be able
to call it from VBScript
It has a class with one method & the IDL is as follows
[id(1), helpstring("method GetSecret")] HRESULT GetSecret([in]
VARIANT Name, [in] VARIANT Password, [in] VARIANT Level, [out,retval]
VARIANT* Secret);
I'd like to point out that you don't have to make all parameters
VARIANTs for a method to be callable from VBScript. Unless you really
want to be able to pass parameters of varying types at runtime (e.g.,
pass an integer for Name), declare them with a specific type, such as a
BSTR.
The server is written using ATL and the routine is fairly simple. The
first 2 in variables are strings, the third is Long
Not really. They are whatever the client happens to pass in. It is your
responsibility now to do type coercion, and/or reject parameters of a
wrong type.
The above code works no problems - HOWEVER I don't seem to know how
to call this from VB
Debug, check the .vt fields of VARIANT's you get in. My guess is, you
get variants of type VT_VARIANT | VT_BYREF, and the referred-to variant
in turn holds a string or an integer.
So it is clear that the VB call is not
correct
The call is correct - your expectations of possible parameter values are
not.
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925