Hi all,
I have to include a C style DLL into C#. The dll has a function which should give me back a string, an array of integer and a single integer.
The DllImport looks like this:
The C# source to call the function:
The value, the msg and the rSize is correct.
Result should contain 7 values greater than 0, but I only get the first one, and the size of the array also changed from 7 to 1.
The first value of result is correct.
I also got the function in C style, here you have to use a pointer to pointer to get the values:
Can anybody help me how to get the other 6 values of result?
Thanks!
Greetings!
I have to include a C style DLL into C#. The dll has a function which should give me back a string, an array of integer and a single integer.
The DllImport looks like this:
Code:
[DllImport("key2.dll", EntryPoint = "#4")]
public static extern bool measureKey(ref StringBuilder msg, int[] Params,byte[] Result,ref int rSize);
Code:
int[] parameter = new int[5]; parameter[0] = 5300; parameter[1] = 4700; parameter[2] = 4000; parameter[3] = 0; parameter[4] = 80; StringBuilder msg = new StringBuilder(128); int rSize = 0; int[] result = new int[7]; [B] bool value = measureKey(ref msg, parameter, ref result, ref rSize);[/B]
Result should contain 7 values greater than 0, but I only get the first one, and the size of the array also changed from 7 to 1.
The first value of result is correct.
I also got the function in C style, here you have to use a pointer to pointer to get the values:
Code:
int * Result;
int rSize;
char * Msg;
int Params[EXPECTEDVALUES];
retval = measureKey(&Msg, Params, &Result, &rSize);
if (!retval) {[INDENT]printf("Error: ");
printf(Msg);[/INDENT]
}else{[INDENT]printf("Success: ");
for(y = 0; y < rSize; y++){[/INDENT][INDENT][INDENT]printf("%d ",Result[y]);[/INDENT][/INDENT][INDENT]}[/INDENT]}
printf(Msg);
free(Result);
}
Thanks!
Greetings!
Comment