One way is using C++/CLI and use your unmanaged DLL directly as it is done if C++. Using C++/CLI, create a public wrapper managed ("ref") class. You wrapper project should be mixed-mode (managed+unmanaged). On output, you get a library which can be uses as a normal .NET library. You can reference by any other .NET Assembly.
The second way is using C# only and P/Invoke. Your case is extremely simple; how come it could be a problem? Do this:
using dword = System.UInt32;
using DllImportAttribute = System.Runtime.InteropServices.DllImportAttribute;
class MyWrapper {
const string LibraryName = "MyUnmanaged.DLL";
[DllImport(LibraryName, EntryPoint = "BuzzerState")]
internal static extern bool BuzzerState(dword dwState);
[DllImport(LibraryName, EntryPoint = "BuzzerRegRead")]
internal static extern dword BuzzerRegRead(dword RegNum);
}
The named parameter
EntryPoint
is redundant here, but I recommend to use it because the exported name could be different (
name mangling, which is your case is suppressed by "extern C"). It's best to check up what is actually exported using some binary dump tool such as "dumpbin.exe" — use it from Visual Studio Command Prompt.
See:
http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.dllimportattribute.aspx[
^],
http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.aspx[
^],
Name mangling, aka
name decoration:
http://en.wikipedia.org/wiki/Name_decoration[
^].
—SA