win32dll.cpp 594 B

12345678910111213141516171819202122232425262728293031323334
  1. // win32dll.cpp : 定义 DLL 应用程序的导出函数。
  2. //
  3. #include "stdafx.h"
  4. //#include "win32dll.h"
  5. #ifdef WIN32DLL_EXPORTS
  6. #define MYDLL_API _declspec(dllexport) // 导出dll函数,供外部使用;
  7. #else
  8. #define MYDLL_API _declspec(dllimport) // 导出dll函数,供dll内部使用;
  9. #endif // NONMFCDLL_EXPORTS
  10. #ifdef __cplusplus
  11. extern "C"
  12. {
  13. #endif
  14. MYDLL_API int g_result;
  15. MYDLL_API int add(int a, int b);
  16. MYDLL_API int add2(int a, int b);
  17. #ifdef __cplusplus
  18. };
  19. #endif
  20. // 函数实现可以在extern "C"外实现;
  21. int add(int a, int b)
  22. {
  23. return g_result = a+b;
  24. }
  25. int add2(int a, int b)
  26. {
  27. return g_result +a+b;
  28. }