Interface Prototypes


J

Jeff Gaines

I posted this to the interop group but no response so far, hope people
don't mind my asking here.

I have down-loaded and am trying to understand a MSFT sample "Windows API
Code Pack 1.1".

In one of the comments it says:
To successfully import a COM interface, all inherited methods need to be
declared again with the exception of those already declared in IUnknown".

None of my interface prototypes do this, I didn't know it was necessary!
Interestingly they still seem to work though.

Is this correct?

I found a contradiction when I created a class based on the
IExplorerBrowser interface. My prototype for IExplorerBrowser defined it
as inheriting from IUnknown (rightly or wrongly) and the compiler
complained that I hadn't implemented the prototypes of IUnknown in the
class.

I would appreciate any comments or links so I can try and understand this
better!
Is there a definitive source of C# interface prototypes? Pinvoke.net is
good but I'm not sure it's definitive.
 
Ad

Advertisements

J

Jeff Gaines

As far as definitive sources go, I would say MSDN is the definitive source.
Here's a good place to start:
http://msdn.microsoft.com/en-us/library/ms172270.aspx

Now that's a right riveting read :)
Thanks, Peter.

Without code and links to references you're using, it's hard to know
exactly what issues you may or may not be having. In general, a managed
COM interface has to declare all the members in the original COM interface,
and a managed COM implementation has to implement all the members in the
original COM interface. The exception for IUnknown exists because .NET
handles the AddRef/Release semantics on the COM side. It's been a few
years so I don't recall how QueryInterface is handled, but I have a vague
recollection that this is overridable in a custom implementation, where the
default behavior is that QI will only ever return the declared COM
interface implementation.

The Windows API Code pack is at:
http://archive.msdn.microsoft.com/WindowsAPICodePack

I think, since it is MSFT code, I probably ought to update my own
definitions in line with MSFT's - or just use the dll it produces.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top