I am a C / C ++ programmer, but I was asked to update a program written in C # to communicate with the device. My knowledge of C # is very simple.
The previous version was completely written in C #, but now the API that actually got access to the device has been changed to C. I found out that I can import the C API functions using:
[DllImport("myapi.dll")]
public static extern int myfunct(
[MarshalAs(UnmanagedType.LPTStr)] string lpDeviceName,
IntPtr hpDevice);
In C, this function prototype:
int myFunct( LPTStr lpDeviceName, HANDLE* hpDevice );
Where the HANDLE is defined as:
typedef void *HANDLE;
However, this function does not work as expected. Actually, in C # code, what type of type should I declare and go to the C # method?
Thanks for the help and sorry for any stupid question.
source
share