You might have more success passing a byte array as the buffer into the
function and then extract the result out into your array of custom classes
e.g.
[DllImport("ADCARD.DLL", EntryPoint="ADResult", SetLastError=true)]
private extern static int ADResult(byte[] Buf);
byte[] buffer = new byte[4000];
int result = ADResult(buffer);
If the function is failing (returning no data into the buffer) what is the
return value from the function - place a breakpoint after calling the
function and look at the value of result (or r in your code).
Peter
--
Peter Foot
Windows Embedded MVP
OpenNETCF.org Senior Advisor
www.inthehand.com |
www.opennetcf.org
"Charles Wang" <(E-Mail Removed)> wrote in message
news:u#81$$(E-Mail Removed)...
> Hello Everyone!
>
> I want to get data from a A/D card.
>
> All functions that control this A/D card are included in ADCard.dll,
native
> code;
>
> I import functions using DllImport. Other functions, such as Initial() and
> StarIntr() etc, work fine except ADResult();
>
> ADResult() is defined as int __stdcall ADResult(ADCard_Result * Buf).
>
> ADCard_Result is a struct:
> typedef unsigned short ADValueType;
> typedef struct structADResult {
> ADValueType SeqNo;
> ADValueType ADValue[1];
> } ADCard_Result;
>
> I import this function like this:
> public struct ADCard_Result
> {
> ushort SeqNo;
> ushort ADValue;
> }
> [DllImport("ADCARD.DLL", EntryPoint="ADResult", SetLastError=true)]
> private extern static int ADResult(ADCard_Result[] Buf);
>
> In main progress I call this function like this:
> ADCard_Result[] pResult = new ADCard_Result[10000];
> pResult.Initialize();
> int r = ADCard(pResult);
>
> But all the pResult[0-10000] is 0. I alse use out and ref but they take no
> effect.
>
> Any suggestion is welcome! Thanks!
>
>