Harry Boy
Harry Boy

Reputation: 4777

Pass a Struct from C++ to CLI

The following struct is passed from C++ to CLI (To be used by a C# project). It is passing an int and an array of structs:

public value struct CallbackInfo
{
public:
    int callbackType;
    [MarshalAsAttribute(System::Runtime::InteropServices::UnmanagedType::ByValArray, ArraySubType = System::Runtime::InteropServices::UnmanagedType::LPStruct, SizeConst=1)] array<SystemInfo>^ SystemInfo;     
};

How do I modify this so that it only passes a single copy of the struct SystemInfo? And not an array which is of size 1??

Upvotes: 1

Views: 146

Answers (1)

David Heffernan
David Heffernan

Reputation: 613612

Declare it like this:

public value struct CallbackInfo
{
public:
    int callbackType;
    SystemInfo systemInfo;     
};

Upvotes: 1

Related Questions