well, it seems to me that the best solution in your case, provided you know
how to write what you want in C, is to use Interop technology.
Interop is the technology which let you declare you C function prototype in
a C# class and then just uses them!
exemple:
//------------ example.cs -----------------
using System.Runtime.InteropServices;
using System.Security;
[SuppressUnmanagedCodeSecurity] // better perf, less security
public class SysFunctions
{
const string KERNEL32 = "Kernel32";
[DllImport(KERNEL32, SetLastError = true, CallingConvention =
CallingConvention.Winapi)]
private static extern IntPtr LoadLibrary(string libname);
public static void Init()
{
if(LoadLibrary("mylib.dll") == IntPtr.Zero)
throw new InvalidOperationException("can't find mylib");
}
}
// -------------------
Look for interop in the documentation. (just type 'interop' in the
documentation index, or try google
Alternatively you could write a managed C++ wrapper, if there are heaps of
function / structure to defined.
That would gives you the more power with less work to do (but comes with a
lot of C++ fussyness).
Here is a link about managed C++ 2.0 syntax:
http://msdn2.microsoft.com/library/xey702bw(en-us,vs.80).aspx
// ------ exemple.h ---------
#pragma once
#include <windows.h>
using namespace System;
public ref class SysFunctions
{
public:
static void Init()
{
HMODULE h = LoadLibrary("mylib.dll");
if( !h )
throw gcnew InvalidOperationException("Can't find mylib");
}
};
// -------------------------