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






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

Answer / krishna akkulu

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
VARIANT).

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:

[uuid(21602F40-CC62-11d4-AA2B-00A0CC39CFE0)]
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;
};
For more info see : http://vcfaq.mvps.org/com/4.htm

Is This Answer Correct ?    0 Yes 3 No

Post New Answer




More COM DCOM Interview Questions

C is aggregated by B, which in turn aggregated by A. Our client requested C. What will happen?

2 Answers  


Which namespace do the classes, allowing you to support COM functionality, are located?

0 Answers  


Write a JCL to copy only selected members from a partitioned data set to another partitioned data set. (Use: IEBCOPY)

1 Answers   Wipro,


what is oops

11 Answers   Accenture,


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

1 Answers  






What are the purposes of AddRef, Release and QueryInterface functions

2 Answers  


What is IUnknown? What methods are provided by IUnknown?

3 Answers   IBM,


What should QueryInterface functions do if requested object was not found?

1 Answers  


Explain object pooling?

1 Answers   HCL,


Differentiate normal DLL to COM DLL

7 Answers   Talisma,


how do you know it is general dll or com dll

5 Answers  


What is the difference, if any, between OLE and COM?

3 Answers  






Categories