A question about call dll in c#

B

Beareye

there is a function in UA2011.dll :

void stdcall read_201(HANDLE h201, short *addat, unsigned long leng)


Now I write this code in c# like this:


Class Uac:
[DllImport ("UA200.DLL") ]
public static extern void read_201(int h201, IntPtr addat,long
leng);


I use read_201 to collect data,and then put into addat array:


IntPtr addat;
int result=Uac.OpenUA201(); // open handle
Uac.Start(result,0,8,2000,0); //init
Uac.read_201(result,addat,32);


but I got an error that I use a parameter not evaluated. I am not sure
how to use IntPtr addat,
who can tell me?thank you
 
M

Mattias Sjögren

[DllImport ("UA200.DLL") ]
public static extern void read_201(int h201, IntPtr addat,long
leng);


The last parameter shoud be of type int in C#.

Can't you make the addat parameter a ref short or short[] depending on
how it's used?



Mattias
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top