Guest User

Untitled

a guest
Jan 17th, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. #ifdef IMPORTDLL_EXPORTS
  2. #define IMPORTDLL_API __declspec(dllexport)
  3. #else
  4. #define IMPORTDLL_API __declspec(dllimport)
  5. #endif
  6.  
  7. // This class is exported from the ImportDLL.dll
  8. class IMPORTDLL_API CImportDLL {
  9. public:
  10. CImportDLL(void);
  11. // TODO: add your methods here.
  12. int Add(int a , int b);
  13. };
  14.  
  15. extern IMPORTDLL_API int nImportDLL;
  16.  
  17. IMPORTDLL_API int fnImportDLL(void);
  18. IMPORTDLL_API int fnMultiply(int a,int b);
  19.  
  20. #include "stdafx.h"
  21. #include "ImportDLL.h"
  22.  
  23.  
  24. // This is an example of an exported variable
  25. IMPORTDLL_API int nImportDLL=0;
  26.  
  27. // This is an example of an exported function.
  28. IMPORTDLL_API int fnImportDLL(void)
  29. {
  30. return 42;
  31. }
  32.  
  33. IMPORTDLL_API int fnMultiply(int a , int b)
  34. {
  35. return (a*b);
  36. }
  37.  
  38. [DllImport("ImportDLL.dll")]
  39. public static extern int fnMultiply(int a, int b);
  40.  
  41. extern "C" MYDLL_API int __stdcall fnMultiply(int a, int b)
  42. {
  43. return a*b;
  44. }
  45.  
  46. // Note: update also the .h DLL public header file with __stdcall.
  47.  
  48. LIBRARY MYDLL
  49. EXPORTS
  50. fnMultiply @1
  51. ...
  52.  
  53. [DllImport("MyDLL.dll)]
  54. public static extern int fnMultiply(int a, int b);
  55.  
  56. extern "C" IMPORTDLL_API int fnMultiply(int a , int b)
  57. {
  58. return (a*b);
  59. }
Add Comment
Please, Sign In to add comment