Re: COM:- passing a variant by reference...
From: Ashok K Kumar (AshokKKumar_at_discussions.microsoft.com)
Date: 12/02/04
- Next message: Ashok K Kumar: "Re: manual Control Messages in MFC"
- Previous message: Mark: "Text on a toolbar"
- In reply to: Thomas Sedlaczek: "COM:- passing a variant by reference..."
- Next in thread: Thomas Sedlaczek: "Re: COM:- passing a variant by reference..."
- Reply: Thomas Sedlaczek: "Re: COM:- passing a variant by reference..."
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 2 Dec 2004 23:00:19 +0530
You are set a wrong values to the Variant. VT_I4 | VT_BYREF means that the
variant should a pointer to a long value and the data member should "plVal"
and not "lVal".
By the way I thought you want assign a value to a variable that is passed by
ref to your COM component. For that you just have to clear the value held by
the variant pointer and set the new value like below.
VariantClear(vVal);
vVal->vt = VT_I4; //you should not use BYREF here, since you are assigning a
value not a reference.
vVal->lVal = 10; //or some number
--
------------------------------
Ashok K Kumar
------------------------------
"Thomas Sedlaczek" <ThomasSedlaczek@discussions.microsoft.com> wrote in
message news:1490F4CA-C1DB-4831-AFA4-9AEF8C09FC28@microsoft.com...
> Hello,
>
> How can I pass a variant type by reference from a VBscript to my COM
> dispatched function? I have tried the code below but assigning a new value
> does not change the value of the referenced VBscript variable. What I am
> doing wrong? Where can I find an example?
>
> Best regards,
> Thomas
>
> DISP_FUNCTION(MyScriptObject, "FunctionByReference", FunctionByReference,
> VT_EMPTY, VTS_VARIANT) // VTS_PVARIANT delivers also a type mismatch.
>
> void MyScriptObject::FunctionByReference(VARIANT* vVal)
> {
> vVal->vt = VT_I4|VT_BYREF;
> vVal->lVal = ...; // assign new value
> }
>
- Next message: Ashok K Kumar: "Re: manual Control Messages in MFC"
- Previous message: Mark: "Text on a toolbar"
- In reply to: Thomas Sedlaczek: "COM:- passing a variant by reference..."
- Next in thread: Thomas Sedlaczek: "Re: COM:- passing a variant by reference..."
- Reply: Thomas Sedlaczek: "Re: COM:- passing a variant by reference..."
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|
|