The basic process is the same whether you call Win32.dll or Mfc.dll
The following is an example of a Mfcdll project called VC + + written by Callmfcdll C # project
1, add in the MFCDLL.h
extern "C" __declspec (dllexport) int add (int x,int y);//Export function
2, add in the MFCDLL.cpp
extern "C" __declspec (dllexport) int add (int x,int y)
{
focus=100;
return x+y;
}
3. Change the output directory of the DLL
Mfcdll Properties Page--Configuration Properties--general---Output directory, edited as Callmfcdll Deug path, so click Generate Mfcdll, in the Debug folder there are MFCDLL.dll, MFCDLL.lib and other files
4. Create a new class in Callmfcdll specifically for calling DLLs, such as CallDllFunction.cs
Add in the CallDllFunction.cs
Using System.Runtime.InteropServices;
......
......
Export function
[DllImport ("MFCDLL.dll", EntryPoint = "Add", ExactSpelling = False, CallingConvention = callingconvention.cdecl)]
public static extern int add (int x, int y);
5, the last can be passed similar to "Calldllfunction.add (10, 20);" method in the form of calling the DLL.
C # Calling DLL Small example