J
juergen
hello,
i want to use a c dll in c#.
it is only one method but it doesn't work.
this is the c method in the dll:
int vciMulticastSearch(int iColorNumber, int maxRequests, PMCAST_DATA pData, int maxData,
char *pszIpLan,char *pszIpWlan);
PMCAST_DATA is a structure pointer:
typedef struct
{
int iColor;
int iState;
int iMedium;
int isLAN;
int ipMask;
int iModeWLan;
char szSN[16];
char szMacLan[18];
char szMacWLan[18];
char szIP[16];
char szTester[32];
char szApplication[32];
char szText[32];
int iMediumTester;
} MCAST_DATA, *PMCAST_DATA;
i tried this c# method:
[DllImport("my.dll", ExactSpelling=true)]
public static extern int vciMulticastSearch(int iColorNumber, int maxRequests, MCAST_DATA [] pData,
int maxData, [MarshalAs(UnmanagedType.LPStr)] string pszIpLan,
[MarshalAs(UnmanagedType.LPStr)] string pszIpWlan);
i defined the struct in c# too:
public struct MCAST_DATA
{
.....
public int iModeWLan;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=16)] public string szSN];
.....
}
but the problem is that i need to initialize a array of that struct in c# like that:
MCAST_DATA [] data = new MCAST_DATA[10];
and then get the pointer of that array and give it to the vciMulticastSearch method.
how can i do that??
i tried the intptr of the first element in the array but the array never gets filled.
please help.
bye bembi
i want to use a c dll in c#.
it is only one method but it doesn't work.
this is the c method in the dll:
int vciMulticastSearch(int iColorNumber, int maxRequests, PMCAST_DATA pData, int maxData,
char *pszIpLan,char *pszIpWlan);
PMCAST_DATA is a structure pointer:
typedef struct
{
int iColor;
int iState;
int iMedium;
int isLAN;
int ipMask;
int iModeWLan;
char szSN[16];
char szMacLan[18];
char szMacWLan[18];
char szIP[16];
char szTester[32];
char szApplication[32];
char szText[32];
int iMediumTester;
} MCAST_DATA, *PMCAST_DATA;
i tried this c# method:
[DllImport("my.dll", ExactSpelling=true)]
public static extern int vciMulticastSearch(int iColorNumber, int maxRequests, MCAST_DATA [] pData,
int maxData, [MarshalAs(UnmanagedType.LPStr)] string pszIpLan,
[MarshalAs(UnmanagedType.LPStr)] string pszIpWlan);
i defined the struct in c# too:
public struct MCAST_DATA
{
.....
public int iModeWLan;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=16)] public string szSN];
.....
}
but the problem is that i need to initialize a array of that struct in c# like that:
MCAST_DATA [] data = new MCAST_DATA[10];
and then get the pointer of that array and give it to the vciMulticastSearch method.
how can i do that??
i tried the intptr of the first element in the array but the array never gets filled.
please help.
bye bembi