OOPortal OOPortal


Basic COM  «Prev 

COM interface properties

Generating IIDs

A predefined macro called DEFINE_GUID is used to define IIDs as variables in your code. Microsoft provides a tool called guidgen to generate IIDs and DEFINE_GUID macros.
COM guidgen tool

Guidgen will generate a DEFINE_GUI macro for you. Click the New GUID button to generate a new GUID. Click the Copy button to copy the DEFINE_GUID macro with the generated IID copied into the clipboard. Paste the DEFINE_GUID macro into your code. Replace <<name>> with the interface name. For example:

Essential COM
DEFINE_GUID(<<name>>, 
0xc4cf2171, 0x4832, 0x11d2, 0x85, 0xbc, 0x8,
0x0, 0x17, 0x0, 0xc5, 0x7f);

Replace <<name>> with the name of your interface:
DEFINE_GUID(IMyComInterface, 
0xc4cf2171, 0x4832, 0x11d2, 0x85, 0xbc, 0x8,
0x0, 0x17, 0x0, 0xc5, 0x7f);