Discussion:
Two ActiveX with passing a variant array
(too old to reply)
R.Wieser
2021-01-03 18:43:07 UTC
Permalink
Hello all,

From within some vbscript I'm calling a method in a simple ActiveX object,
providing it a two-dimensional array, and have two problems :

1) How to I define, in the TypeLib (IDL) file, that I want to pass a
(pointer to a) variant array ? Currently I have this :

HRESULT VarArray([in] variant* Array);

The thing is that this causes the VarArray method to receive a variant which
in turn holds a pointer to the Array, instead of just receiving a simple
pointer to the Array.

2) For some reason the above mentioned received variant has the pointer to
the Array in bytes 0x0C...0x0F of the VARIANT structure, instead of in bytes
0x08...0x0B (as described here :
https://docs.microsoft.com/en-us/windows/win32/api/oaidl/ns-oaidl-variant ),
and I've got no idea why.

The used OS version is XPsp3

Regards,
Rudy Wieser
R.Wieser
2021-01-03 21:05:29 UTC
Permalink
Post by R.Wieser
Hello all,
...
Post by R.Wieser
2) For some reason the above mentioned received variant has the pointer to
the Array in bytes 0x0C...0x0F of the VARIANT structure, instead of in
bytes 0x08...0x0B
It turns out that the bytes 0x08...0x0B are a pointer to the address holding
the pointer to the array - in this case pointing to the bytes at
0x0C...0x0F.

No idea (yet) why its a pointer-to-a-pointer, but that is how it works.

Currently only question #1 remains : what do I need to put into the TypeLib
file to get a simple pointer to the, in the script provided, array. So
that I do can skip the part checking the (what I now get) variant for its
type and pointer-to-pointer contents.

Regards,
Rudy Wieser
JJ
2021-01-04 08:02:28 UTC
Permalink
Post by R.Wieser
Hello all,
From within some vbscript I'm calling a method in a simple ActiveX object,
1) How to I define, in the TypeLib (IDL) file, that I want to pass a
HRESULT VarArray([in] variant* Array);
The thing is that this causes the VarArray method to receive a variant which
in turn holds a pointer to the Array, instead of just receiving a simple
pointer to the Array.
2) For some reason the above mentioned received variant has the pointer to
the Array in bytes 0x0C...0x0F of the VARIANT structure, instead of in bytes
https://docs.microsoft.com/en-us/windows/win32/api/oaidl/ns-oaidl-variant ),
and I've got no idea why.
The used OS version is XPsp3
Regards,
Rudy Wieser
You'll have to define a custom COM Record type to represent the raw array,
then use that as the method arguments.
R.Wieser
2021-01-04 08:48:41 UTC
Permalink
JJ,
Post by JJ
You'll have to define a custom COM Record type to represent
the raw array, then use that as the method arguments.
Whoah ... Thats an area I've never worked in ... For now I think I'm going
to pass on that.

As for "the raw" data, the conversion works flawlessly for variants that are
received as longs, booleans, bstr's, etc. (including silent type
conversions). I would assume that "extracting" (if you can even call it
that) a SafeArray from the provided vbs array and receive that could/would
work the same way.

Looking at what I have to do to extract the SaveArray myself it doesn't look
like rocket science. Am I perhaps missing something there ?

Regards,
Rudy Wieser

Loading...