I
Ilya Konstantinov
Hi,
Suppose[1] in some 3rd-party COM-based API there's a method which
returns an IFooBar object:
HRESULT GetFooBar(IFooBar **pvFooBar);
and then for interop you convert this method to:
IFooBar GetFooBar();
and then, from your .NET code, you'd do:
IFooBar myBar = GetFooBar();
myBar->doSomething(); // at this point, QueryInterface occurs
The problem is, this COM object wasn't written with the best practices
in mind; while the returned pvFooBar is already QI'd and ready for use,
attempting to QI it for IID_IFooBar returns E_NO_SUCH_INTERFACE.
Is there any way in .NET CF to prohibit the automatic QI and just tell
it "Assume the return pointer is already QI'd, and just use it"?
[1] The "imaginary COM object" is actually the Pocket PC 5.0 Imaging
API JPEG encoder (IImageEncoder) whose GetEncodeSink() returns an
IImageSink which cannot QI to IID_IImageSink.
Suppose[1] in some 3rd-party COM-based API there's a method which
returns an IFooBar object:
HRESULT GetFooBar(IFooBar **pvFooBar);
and then for interop you convert this method to:
IFooBar GetFooBar();
and then, from your .NET code, you'd do:
IFooBar myBar = GetFooBar();
myBar->doSomething(); // at this point, QueryInterface occurs
The problem is, this COM object wasn't written with the best practices
in mind; while the returned pvFooBar is already QI'd and ready for use,
attempting to QI it for IID_IFooBar returns E_NO_SUCH_INTERFACE.
Is there any way in .NET CF to prohibit the automatic QI and just tell
it "Assume the return pointer is already QI'd, and just use it"?
[1] The "imaginary COM object" is actually the Pocket PC 5.0 Imaging
API JPEG encoder (IImageEncoder) whose GetEncodeSink() returns an
IImageSink which cannot QI to IID_IImageSink.