Hello,
I have a C# program going and want to be able to call the DLL and receive back the data requested through a pointer.
Below is the DLL import within my C# code.
Code:
[DllImport("MyTest.dll")]
public static extern int ReadNetwork(Byte[] ROM_ID);
Below is the code in the DLL
Code:
int _stdcall ReadNetwork(unsigned char* Array1)
{
ReadDevice(readBackArray);
for(i = 0; i < 20; i++)
{
Array1[i] = readBackArray[i];
}
return 1;
}
And below how I'mm calling the DLL and trying to print out the results.
Code:
int errorCheck;
byte[] testArray;
testArray = new byte[12];
string value;
errorCheck = ReadNetwork(testArray);
MessageBox.Show("Return Value: " + errorCheck.ToString());
value = ASCIIEncoding.ASCII.GetString(testArray);
MessageBox.Show("Array String: " + value);
I've tried changing the return values in the DLL's ReadNetwork() function and that works ok, so I know I'm calling the DLL and it runs ok, but printing the result back is where I'm having the problem. Any help will be appreciated.