_ Stdcall is the standard for Windows function calls. Pascal and winapi are the same.
The default call Convention for C is _ cdecl.
DLL project:
// Mydll. h # ifdef mydll_header # else # define mydll_header extern "C" _ declspec (dllimport) # endifmydll_header int _ stdcall add (int A, int B ); mydll_header int _ stdcall substract (int A, int B);/* class mydll_header point {public: Point (int A, int B): X (A), y (B) {} void output (); Private: int X, Y ;}; */////////////////////////////////////// //////////////////////////////////////// /// // mydll. CPP # define mydll_header extern "C" _ declspec (dllexport) # include "mydll. H "# include" windows. H "# include" stdio. H "int _ stdcall add (int A, int B) {return a + B;} int _ stdcall substract (int A, int B) {return a-B ;} /* member function void point: output () {hwnd handle = getforegroundwindow (); HDC Dc = getdc (handle); char Buf [20]; sprintf (BUF, "x = % d, y = % d", this-> X, this-> Y); textout (DC, 0, 0, Buf, strlen (BUF); releasedc (handle, DC );}*/
Caller:
// client. CPP # include "mydll. H "//... void cmydlltestdlg: onbuttonadd () {cstring STR; Str. format ("5 + 3 = % d", add (5, 3); MessageBox (STR);} void cmydlltestdlg: onbuttonsubstract () {cstring STR; Str. format ("5-3 = % d", substract (5, 3); MessageBox (STR);} void cmydlltestdlg: onbuttonoutput () {// point Pt (11, 3222 ); // PT. output () ;}