The C++ code is:
DLL_API DWORD WINAPI ExecuteCommand( LPCSTR, CONST COMMAND, CONST DWORD, LPREPLY);
typedef struct
{
REPLY_TYPE replyType;
union
{
POSITIVE_REPLY positiveReply;
NEGATIVE_REPLY negativeReply;
}
message;
}
REPLY;
And my C# code is:
public struct Reply
{
public ReplyType ReplyType;
public PositiveReply PositiveReply;
public NegativeReply NegativeReply;
}
[DllImport(@"my.dll")]
public static extern int ExecuteCommand(string port, Command command, int timeout, ref Reply reply);
How can I properly transfer union to C# code? When I call ExecuteCommand I receive reply which should contain either Positive or Negative Reply (such does C++ method).