Re: Pointer Marshalling quesiton

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Well, I guess I'm out of practice on advanced IDL...
When I think about it, this is the same situation as with the
IEnumXXX family of interfaces.

One solution would be to use a [local]/[call_as] pair of
methods. Pass a stack variable to always receive the
interface pointer in your proxy shim and only return it to
the caller if it passed non-NULL pointer, otherwise release
it. I've posted local/call_as sample code in the past - you
may want to search the archives on Google groups.

The above solution is not very elegant I admit, since it still
involves interface pointer marshling. You may prefer to use
[wire_marshal] instead, though I have no direct experience
with that method of argument marshaling to advise you.

--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD
email: agnickolov@xxxxxxxx
MVP VC FAQ: http://vcfaq.mvps.org
=====================================

"jonathannah" <jonathannah@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:632242B4-6E79-474F-93EE-6EA0F5AEF4BB@xxxxxxxxxxxxxxxx
Refer to the original post. The parameter is [out] IUnknown** ppUnk.
Midl
will not allow you to specify unique or ptr modifier. it gives a compile
error.

error MIDL2121 : [out] only parameter must not derive from a top-level
[unique] or [ptr] pointer/array : [ Parameter 'ppUnk' of Procedure 'Bar'

"Alexander Nickolov" wrote:

Just add the [unique] attribute. The default is [ref]. Note it works
for [out] pointers too, not only [in, out]. [ptr] will do as well, but
it's heavier on the marshaling since it checks for pointer aliasing.

--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD
email: agnickolov@xxxxxxxx
MVP VC FAQ: http://vcfaq.mvps.org
=====================================



.



Relevant Pages

  • Re: CoMarshalInterThreadInterfaceInStream FinalRelease not called
    ... You need to marshal the ougoing interface, ... Microsoft MVP, MCSD ... "Alexander Nickolov" wrote: ... interface pointer is working as intended but my FinalRelease is not ...
    (microsoft.public.vc.atl)
  • Re: How to pass COM object created in one EXE into another EXE, an
    ... You need to store a single pointer to C somewhere within A ... Alexander Nickolov ... > I did not do any interface marshal for DLL_C, ... >> Microsoft MVP, MCSD ...
    (microsoft.public.vc.atl)
  • Re: Getting the interface pointer for current object
    ... "Alexander Nickolov" wrote in message ... Note the returned interface pointer is _not_ ... > Microsoft MVP, MCSD ... >> How do you get an interface pointer for the current class object your are ...
    (microsoft.public.vc.atl)
  • Re: ATL OLE DB and SQL Server
    ... > "Alexander Nickolov" wrote in message ... > from that BLOB - the interface might be garbage - you need to ... > hold multiple BLOBs open too, so if you have multiple BLOBs in ... > Microsoft MVP, MCSD ...
    (microsoft.public.vc.atl)
  • Re: CreateNPPInterface
    ... Microsoft MVP, MCSD ... Command-line app, and I neglected to ad all the COM automation headers, ... "Alexander Nickolov" wrote: ... Now the GUI dialog for selecting a network interface works ...
    (microsoft.public.win32.programmer.networks)