Appendix a : importing the dll in c# .net – Sensoray 2251 Rev.A User Manual

Page 48

Advertising
background image

Appendix A : Importing the DLL in C# .NET

Sensoray provides a C DLL for maximum portability between programming languages. This
allows the use of Sensoray SDKs in Visual Basic, C# .NET, Visual C++ and of course C.

The question of how to send structures (with arrays) to any C dll from C# for instance is fairly
common.

There are also some reference materials available from MSDN for using WIN32 DLL calls in
C#.

C# example for using the function SN_SetOverlayText:

In C#, the following can be defined to use this function:

[StructLayout(LayoutKind.Sequential)]
public struct POINT
{
public int x;
public int x;
};

[StructLayout(LayoutKind.Sequential)]
public struct overlay_text_t{
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 96)]
public string text;
public int fontidx;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 28)]
public string reserved;
};

[DllImport("mid2250.dll")]
static extern int SN_SetOverlayText(int idx, ref POINT position,
ref overlay_text_t text,
bool enable, bool update,
int board);

48

Advertising
This manual is related to the following products: