Hi,
Please, does anybody know how can the code bellow to C# ?
C++ structure
typedef struct SMAP_INFO
{
WORD wPort;
DWORD dwSerialNumber;
WORD wHardComp;
BYTE bFirmwVersion[16];
DWORD dwFirmwDate;
BYTE bMonitorVersion[16];
DWORD dwMonitorDate;
BYTE bRunningProgramID;
} SMapInfo, * PSMAP_INFO;
COM method
virtual HRESULT STDMETHODCALLTYPE GetPortMap(
/* [in] */ WORD wMaxPorts,
/* [out] */ WORD __RPC_FAR *pNumberOfPorts,
/* [size_is][size_is][out] */ SMapInfo __RPC_FAR *__RPC_FAR *pPortMap,
/* [out] */ DWORD __RPC_FAR *pTransactionID) = 0;
How can I change this for C#? I tried the code bellow, but it does work for just 1 structure, however the pPortMap, can have more them only 1 structure, i.e., it is pointer to an array of "n" struture.
C#
[StructLayout(LayoutKind.Sequential, Pack = 2, CharSet = CharSet.Unicode)]
public class SMAP_INFO
{
public ushort wPort;
public uint dwSerialNumber;
public ushort wHardComp;
[MarshalAs(UnmanagedType.ByValArray, ArraySubType = UnmanagedType.LPArray, SizeConst = 16)]
public byte[] bFirmwVersion;
public uint dwFirmwDate;
[MarshalAs(UnmanagedType.ByValArray, ArraySubType = UnmanagedType.LPArray, SizeConst = 16)]
public byte[] bMonitorVersion;
public uint dwMonitorDate;
public byte bRunningProgramID;
};
[PreserveSig]
HRESULTS GetPortMap(
[In] ushort wMaxPorts,
[Out] out ushort pNumberOfPorts,
[Out] out SMAP_INFO pPortMap, /* ** The PROBLEM IS HERE */
[Out] out uint pTransactionID);
** How can I define pPortMap to get an array of structure ? Please, detailed code information will be welcome since I an not an expert in C#. Thanks.