How COM stuff works?
Posted on 2006-06-30
First, let me describe the situation. Althought this is a general question, please don't point me to read some MS book about this topic. I'll try to be short.
I am trying to write a Delphi app that works with my SkyStar2 DVB card. The card comes with a file called Sky2PCAVSrc.ax. This file implements some interfaces and can be registered by RegSvr32. I have also the SDK with some documents, but I noticed that the documents and the actual file set do not match! I meant the doc describes such a things that are not supported by the actual driver!!!
So I asked myself: If I cannot rely on the SDK documentation, how can I get the information directly from the driver?
But the file (Sky2PCAVSrc.ax) does not look like a kind of a TypeLib, so I cannot get any interface from it.
Indead, I made a "wild" try: I added a method declaration to the interface defined in the SDK, called "Blabla" with a random parameter list. That means it is a method that absolutely has no corresponding implementation in the driver's code. Then I compiled the application. Certaintly, the compiler did not complain. How could it know that it was a fake method. I had told the compiler that I have an object that implements an interface that has the Blabla method, and the compiler belived me. That was OK.
Then ran the application. It was successful to create the object of fake interface without any error / exception. The call to Blabla returned a negative value, probably saying its execution was failed.
Now my question is how COM stuff works? How can I figure out what is the real interface of the driver? I cannot rely on SDK doc, because it is simply useless. I cannot query the interface's description programatically (maybe because I don't know how). If I make a method call and get error, I even cannot know whether the method doesn't exist at all, or if it exists, but fails because of other reasons.
What shoud you do in this case?