Cody
Cody

Reputation: 639

How does COM client code refer to the IID in the type library?

Compiling a COM client of which the source code contains a line like

#import "../server/IFoo.tlb"

generates ifoo.tlh in the current working directory.

In ifoo.tlh, there are IIDs in string form wrapped by function (or function-like macros) calls, e.g. uuid("6bee2d26-f3d8-11d4-825d-00104b3646c0"), which means the .tlh file definitely knows the values of the IIDs. The question is that in client codes how can I refer to those IIDs without #include any header file of the COM server? In the .tlh file or the .tlb file, are there any (compiled) symbols that represent the IIDs that we can use in the client codes? Thanks.

Upvotes: 2

Views: 256

Answers (1)

Simon Mourier
Simon Mourier

Reputation: 138925

You can use the __uuidof operator (Microsoft Specific):

Retrieves the GUID attached to the expression.

Syntax

__uuidof ( expression )

Upvotes: 3

Related Questions