C#
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
namespace DarkBasicProfessional.Example
{
public unsafe class DGSDK
{
[ DllInput( "..\\LIB\\PinvokeLib.dll", CharSet=CharSet.Auto )
public static extern int Square( int a )
{
return (a * a).ToInteger();
}
}
}
Although this can be a hit'n'miss given DBP only supports cdecl, whereas PInvoke uses stdcall. You're best bet realistically is to make it a class then use C++ .NET to create an interface to DBP.
MSDN2 has all the information you'd need on the subject.
Failing that, realistically .. just make it all in Native C++ and include managed where-ever it's absolutely necessary. Without understanding the COM Interop and PInvoke it is very difficult to get .NET to talk to non-CLR, although possible using unsafe and static pointers (references)
The method above should work for the CallDll command, but it won't work with direct function linking (i.e. TPC DLLs); DBP just can't handle that sort of interaction. Also while I've shown you how to export the function statically to interop with COM and Native code, unsafe is turned off by default (can't turn it on in Express iirc) and you have to program with pointers for any io data which in C# is far trickier to do than C++ as you have to write many classes/types/structs from scratch.