c#与vc调用动态链接库

c#调用 方法

 

Sample DLL "CPPDLL.dll"

in the ".h"

extern "C" __declspec(dllexport) double Add(double x, double y);

 in the ".c" or ".cpp"

__declspec(dllexport) double Add(double x, double y)

{

       return (x*y);

}

     [DllImport(@"CPPDLL.dll", EntryPoint="Add")]

     public extern static double Add( double x, double y);



vc中调用方法:

  *.h

#ifdef DLL_API
#else
#define DLL_API _declspec(dllimport)
#endif

DLL_API int CaptureImg();


*.cpp

#define DLL_API _declspec(dllexport)

int  CaptureImg()


调用的时候在link中添加lib引用 然后include "*.h"



你可能感兴趣的:(C#,VC与MFC)