Variant Size under Win64

Is someone how what is the size of a tagVARIANT under Win64 ?

I only want to create code that works under Win32 and other code that works under Win64.

All i want to do is to pass an array of tagVARIANT between my assembly and IE JScript engine which only works with IDispatchEx interface. My assembly must CALL / CREATE CONSTRUCTOR(Date, Number, Function...) / ASSIGN properties of JScript objects.

I use GetNativeVariantForObject() .NET function which creates perfectly my VARIANT.
Sometimes, a JScript method required more than one parameter, so i must pass it an array of VARIANTS. That's why the size of the tagVARIANT struct is for me important. It works fine under Win32. But with the new Win64 OS, my assembly needs to work also. I need also to compile my assembly with the 64 bits of .NET 2.0 when it will be officialy released.

Type.InvokeMember is not sufficient to do all the things i do by using IDispatch.Invoke() and IDispatchEx.InvokeEx() functions.

.NET framework lacks of a method like
Marshal.GetVariantSize()

[1076 byte] By [RTAG] at [2008-2-12]
# 1
RTAG wrote:
I use GetNativeVariantForObject() .NET function which creates perfectly my VARIANT.
Sometimes, a JScript method required more than one parameter, so i must pass it an array of VARIANTS.
I thinkl you can let GetNativeVariantForObject do all the work for you.


object[] varay = new object [] {"ABC", 1, true};

IntPtr pVaray = Marshal.AllocHGlobal (4000);

try
{
Marshal.GetNativeVariantForObject (varay, pVaray);


Of course it would be nice if you could determine the exact size needed to hold the safearray so you could pass that to AllocHGlobal instead of just guessing as I do above.

I haven't actually tried the code above on a 64-bit system, but it should work (famous last words).

FrankBoyne at 2007-9-9 > top of Msdn Tech,.NET Development,64-Bit .NET Framework Development....

.NET Development

Site Classified