一、DLL部分
1、DLLTest.h
extern "C" _declspec(dllexport) float multiplex(float a, float b);
extern "C" _declspec(dllexport) float divide(float a,float b);
extern "C" _declspec(dllexport) float add(float a,float b);
extern "C" _declspec(dllexport) float subtract(float a,float b);
2、DLLTest.cpp
_declspec(dllexport) float multiplex(float a, float b)
{
return a*b;
}_declspec(dllexport) float divide(float a,float b)
{
return a/b;
}
_declspec(dllexport) float add(float a,float b)
{
return a+b;
}
_declspec(dllexport) float subtract(float a,float b)
{
return a-b;
}
二、测试用例部分
1、Link,DLLTest.lib
2、测试代码:
#include "DLLTest.h"
float a = multiplex(3,5);
CString str;
str.Format("%f",a);
AfxMessageBox(str);