I'd have thought that's where GetNativeVariantForObject would come in. From
"Manny Vellon" <mvellon@vellon.com> wrote in message
news:OzO6T9SOFHA.244@TK2MSFTNGP12.phx.gbl...
> Is there a "Set" analog? If the interface passes a VARIANT * and I
> translate this to IntPtr (so that I can test the incoming pointer value),
> I'd need a "set", but it's not as simple as calling the Marshal.Write's
> because I need a CCW for the object I'm returning.
>
> Another solution that I'm pursuing (as per some reading I've done) is to
> declare the interfaces as arrays:
>
> foo(VARIANT *po, int *pv)
>
> becomes
>
> foo(object[] po, int [] pv)
>
> then I can test po and pv and return values via po[0]= and pv[0]=. This
> should work although it looks weird.
>
> "Nick Hall" <nickh@aslan.nospam.co.uk> wrote in message
> news:u9cMb7QOFHA.4028@tk2msftngp13.phx.gbl...
>> There's also a couple of functions for dealing with variants
>> (GetObjectForNativeVariant/GetNativeVariantForObject) which can be used
>> to similar effect.
>>
>> Hope this helps,
>>
>> Nick Hall
>>
>> "Manny Vellon" <mvellon@vellon.com> wrote in message
>> news:%23oBi789NFHA.2468@tk2msftngp13.phx.gbl...
>>> This works fine for the int pointers, but there's also a VARIANT * in
>>> the interface that requires some special handling. For the ints, there's
>>> some functions in the Marshal class that lets you treat IntPtrs as
>>> memory addresses and lets you write values into them without using
>>> unsafe code.
>>>
>>> Thx.
>>>
>>> "Mattias Sjögren" <mattias.dont.want.spam@mvps.org> wrote in message
>>> news:OYZmGCwNFHA.3512@TK2MSFTNGP15.phx.gbl...
>>>> >Is it totally fruitless to try to deal with optional arguments?
>>>> >Arguably,
>>>>>it's not even strictly an issue with arguments tagged as optional. I
>>>>>can
>>>>>imagine an interface that omits the OPTIONAL keyword but simply
>>>>>documents
>>>>>that NULL pointer values are acceptable. How can this condition
>>>>>(invalid
>>>>>references) be tested in C#?
>>>>
>>>> The only way I can think of is to modify the interop assembly and
>>>> change the parameter types to IntPtr or int*. If you for example
>>>> change the plFlags type to int* (forcing you to use unsafe code in C#)
>>>> you can then write
>>>>
>>>> if ( flags != null )
>>>> *flags = 123;
>>>>
>>>>
>>>>
>>>> Mattias
>>>>
>>>> --
>>>> Mattias Sjögren [MVP] mattias @ mvps.org
>>>>
http://www.msjogren.net/dotnet/ |
http://www.dotnetinterop.com >>>> Please reply only to the newsgroup.
>>>
>>>
>>
>>
>
>