COM DCOM Question:
Download Questions PDF

How to Use structs in COM interfaces when Automation compatibility is not an issue?


Structs, also known as User Defined Types (UDTs), can be
used in Automation- compatible interfaces
An Automation- compatible struct may contain only primitive
Automation types as its members.

Nesting structs is not allowed, but VARIANT is allowed thus
enabling nested structs (you can store a struct in a

In order for a struct to be usable for Automation-
compatible interfaces, the struct must be described in a
type library and it must be declared with its own GUID:

struct MyStruct
[helpstring("A long value")]
long nLongValue;

[helpstring("A string")]
BSTR bstrStringValue;

// Later in the IDL file
[uuid(...), version(...), helpstring(...)]
library MyLib
struct MyStruct;

Download COM DCOM Interview Questions And Answers PDF

Previous QuestionNext Question
What are the different compatibility types when we create a COM component?Do COM keep track of all the object references (Accounting)?