I have got a C DLL and try to transfer Paramter between VB.net and DLL:
Deklaration in VB:
<DllImport("can.dll", CallingConvention:=CallingConvention.StdCall)>
Public Shared Function TransmitSerCanCmd(cmd As UInteger, ByRef pSrcData As Byte(), numScrData As UInteger) As Boolean
End Function
<DllImport("can.dll")>
Public Shared Function ReadSerCanDllVersionInfo(ByRef lpszVersionInfo As String) As UInteger
End Function
All information about can.dll I have is:
BOOL CALLBACK /* successful (TRUE) / failed (FALSE) */
TransferSerCanSrvData /* Transfer service data */
(UINT srv, /* data service (<=127) */
void *pDstData, /* data destination for data read from server */
UINT numDstData, /* number of data to read from server (<=8) */
void *pSrcData, /* data source for data sent to server */
UINT numSrcData); /* number of data to send to server (<=8) */
BOOL CALLBACK /* successful (TRUE) / failed (FALSE) */
ReadSerCanDllVersionInfo /* Read SerCAN protocol dynamic link library version and info */
(LPSTR lpszVersionInfo); /* version and info string (! min. 80 characters) */
In VB.Net I wrote this test:
Dim x1(7) As Byte
Dim x2(3) As Byte
Dim b1,b2 as boolean
x2(0) = 1
x2(1) = 0
x2(2) = 55
b1 = TransferSerCanSrvData(1, x1, 2, x2, 2)
Dim s1 As String
a2 = ReadSerCanDllVersionInfo(s1)
Unfortunately this doesn’t work. I don’t get any information back in Byte Array.
String reference is also not working. Can anybody help please what is missing here? Thanks.
I alredy tried to use other data type without success.
New contributor