I am trying to communicate with an outside instrument using a .dll. I am new to working with dll's and am not sure how to do this. The function calls for the following parameters which I kind of think I am doing right:
[DllImport("MNW. dll", EntryPoint = "mnPollDevices" )]
public static extern unsafe int mnPollDevices([MarshalAs(Unman agedType.LPArra y)] int*[] device_flag,
int* port,
int* buffer,
[MarshalAs(Unman agedType.LPArra y)] char*[] message,
int * devicesFound);
The function should pass an int array of size 128 into the function and when it comes out, the array should contain some values. My problem is actually calling the function. I have tried every combination of pointers and no pointers being sent to the function but am not able to compile. Does anyone know the right syntax? Hardware is the class containing the function. Here is what I am currently using (I know they are not pointers):
int[] flag = new int[128];
int port = 0; //COM1 is 0
int buffer = 128;
int device_Count = 0;
char[] message = new char*[80];
int returncode = 0;
returncode = Hardware.mnPoll Devices(flag, port, buffer, message, device_Count);
[DllImport("MNW. dll", EntryPoint = "mnPollDevices" )]
public static extern unsafe int mnPollDevices([MarshalAs(Unman agedType.LPArra y)] int*[] device_flag,
int* port,
int* buffer,
[MarshalAs(Unman agedType.LPArra y)] char*[] message,
int * devicesFound);
The function should pass an int array of size 128 into the function and when it comes out, the array should contain some values. My problem is actually calling the function. I have tried every combination of pointers and no pointers being sent to the function but am not able to compile. Does anyone know the right syntax? Hardware is the class containing the function. Here is what I am currently using (I know they are not pointers):
int[] flag = new int[128];
int port = 0; //COM1 is 0
int buffer = 128;
int device_Count = 0;
char[] message = new char*[80];
int returncode = 0;
returncode = Hardware.mnPoll Devices(flag, port, buffer, message, device_Count);
Comment