// TestDll.c
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
// compile with compiler option -Gn
BOOL WINAPI DllMain(HANDLE hInstDLL, DWORD dwReason, LPVOID lpvReserved)
{
return TRUE;
}
__declspec(dllexport)
int __stdcall SampleFunction(int a, int b)
{
MessageBox(0, "SampleFunction", "TestDLL", MB_OK);
return a * b;
}
using System;
using System.Runtime.InteropServices;
class MessageBoxTest
{
[DllImport("TestDll.dll")]
static extern int SampleFunction(int a, int b);
public static void Main()
{
int nReturnValue = SampleFunction(1, 2);
}
}