I have the following code that is implemented in a dll file
typedef signed __int16 TS_ELEMENT;
typedef TS_ELEMENT * TS_DATA;
LIBTERAVIEW_API TS_RES tsRead(TS_DATA buffer);
I would like to call this function in my C# program and use it in order to see data that is printed from it. I have read about unmanaged structures and importing functions from DLLs; however, I am not able to figure out the syntax of how to do this in my code. I have generated the following codes based on my readings on this topic:
[DllImport("libteraview.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern void tsStart();
[DllImport("libteraview.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern byte* tsRead(byte* buffer);`
The first one works however, I am not able to get the second method to run and read data as it always gives me an Unhandled Exception error.
I would appreciate any help on how to get this tsRead()
function imported from a DLL.
Please check Return type and Parameter type for tsRead() function. It should be int instead byte.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.