Re: How to casting to VARIANT*
From: Simon Trew (noneofyour_at_business.guv)
Date: 04/30/04
- Next message: agzis: "Re: Problem with size_is in MIDL"
- Previous message: Roger: "Re: How exactly WTL implements menu with bitmap?"
- In reply to: Sankalp: "Re: How to casting to VARIANT*"
- Next in thread: Alexander Nickolov: "Re: How to casting to VARIANT*"
- Reply: Alexander Nickolov: "Re: How to casting to VARIANT*"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 30 Apr 2004 14:54:25 +0100
"Sankalp" <sankalp_reddy@hotmail.com> wrote in message
news:O23XrEqLEHA.1340@TK2MSFTNGP12.phx.gbl...
> Hi,
> Thanks a lot Simon. That worked.
>
> The second parameter to be passed is a range 'object'. The fn. prototype
is
> as follows:
> virtual HRESULT __stdcall Add (
> /*[in]*/ BSTR Name,
> /*[in]*/ VARIANT * Range,
> /*[out,retval]*/ struct Bookmark * * prop ) = 0;
> Is'nt this how objects are passed around (rather than make another copy of
> the object)?
Perhaps I'm mistaken, but it's not usual to pass an IN parameter as a
pointer. I checked the Word type library and it is indeed so; your code is
correct, but I wonder why MSWORD is designed this way. (Perhaps historical?)
I just looked at MSXML by way of comparison, and there are plenty of methods
in there that just take a plain VARIANT.
The Range parameter is marked as Optional, but I don't think this can make a
difference; other parameters in other methods that are not marked as
optional are also passed by pointer. An missing optional variant is usually
passed by setting its type to VT_EMPTY, anyway.
Copying is not really an issue. The server (MSWORD) is out-of-process and so
the object has to be marshalled (copied) across the process boundary anyway.
If I understand it correctly, marking the parameter as [in] means it won't
be marshalled back at the end, so it's not as if you can get any information
back through it.
Even in the in-process case, a VARIANT is only 16 bytes[1], so it's hardly
expensive to make a shallow copy.
S.
[1] On a 32-bit platform. On a 64-bit platform it might be wider, but I
doubt it, because even then a pointer is no wider than a double.
- Next message: agzis: "Re: Problem with size_is in MIDL"
- Previous message: Roger: "Re: How exactly WTL implements menu with bitmap?"
- In reply to: Sankalp: "Re: How to casting to VARIANT*"
- Next in thread: Alexander Nickolov: "Re: How to casting to VARIANT*"
- Reply: Alexander Nickolov: "Re: How to casting to VARIANT*"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|