Where Oh Where is my DISPID???!!!!
Life is such a journey. And sometimes what is old is new again. For those of you who have been reading my blog for the last 2 months you know that I’ve been working on a C++ COM sample for the Digipede Network. I’m not working on this full-time so I’m not a complete idiot for not finishing yet! But I’m learning new things and remembering old things. I often feel like I’ve forgotten more software techniques and technologies than I remember. And today is no exception. The focus of my interest recently has been creating a sink (to handle Digipede events). One of the problems I ran into is without access to the Digipede source code, how would a developer know what the DISPID values are to hook up the sink? How should my code define the event when one of the values I’m receiving is defined as an object?
Well, here is the answer to that part of the puzzle.
1. From your Visual Studio environment, from the menu bar select Tools->OLE/COM Object Viewer. You now have the OLE/COM Object Viewer application open.
2. From the OLE/COM Object Viewer’s menu bar select File->View TypeLib.... In the Open dialog box navigate to a Digipede.Framework.dll file and select the file for opening. My Digipede.Framework.dll is located in "C:\Program Files\Digipede\Framework SDK\v1.2\Net1.1".
3. Now what you should see is the ITypeLib Viewer window with the Digipede.Framework.dll’s type library displayed.
We are now at the point where we can get important information that we need. In the left hand column is a list of all the methods and interfaces available from the Digipede.Framework.dll file. Right now I’m interested in the IDigipedeClientEvents interface. So I expand "coclass DigipedeClient" and from there I can see the IDigipedeClientEvents interface. I then expand the "Methods" and select "JobSubmissionCompleted".
Here is what I see in the right-hand box:
[in] VARIANT sender,
[in] _JobSubmissionCompletedEventArgs* e);
So to get the DISPID that I need I convert the number found in the id, 0x000003e9, from hex to decimal, and I have my DISPID value which is 1001.
I also see that the object value is converted to VARIANT.
I now have two important pieces of information. The DISPID value for JobSubmissionCompleted AND a prototype definition that C/C++ can understand. So the information is there and now I know how to find it.