[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

jas

7/16/2007 10:13:00 PM

Hi

How to convert this union to C# for COM interop?
I thought of having several C# struct types to cover different switch type.
But then what about the default type?
How to make sure that all C# structs have correct default size?

Also, in general, when to convert does the field names matter as long as
they have the correct offset?

Thanks
Jas
--------

typedef struct _VDS_ASYNC_OUTPUT
{
VDS_ASYNC_OUTPUT_TYPE type;

[switch_is(type)] union
{
[case(VDS_ASYNCOUT_CREATELUN)]
struct _cl
{
IUnknown *pLunUnk;

} cl;

[case(VDS_ASYNCOUT_BREAKLUNPLEX)]
struct _blp
{
IUnknown *pLunUnk;

} blp;

// CreateTarget() return value
[case(VDS_ASYNCOUT_CREATETARGET)]
struct _ct
{
IUnknown *pTargetUnk;

} ct;

// CreatePortalGroup() return value
[case(VDS_ASYNCOUT_CREATEPORTALGROUP)]
struct _cpg
{
IUnknown *pPortalGroupUnk;

} cpg;

[default] // This is a dummy member to make the size
struct _dummy // of the union identical to that used
{ // by the service and software provider.
ULONGLONG ull; // (VDS_ASYNCOUT_CREATEPARTITION).
VDS_OBJECT_ID id;
} dummy;
};

} VDS_ASYNC_OUTPUT;