/* main3.c, This is a main program unit for use with the */ /* DLLa and DLLb DLLs. Please refer to the MK3_CF.BAT */ /* file for instruction on building this example */ /* This example demonstrates passing a structure between */ /* DLL and MAIN */ #include #include #include #include #include #include #include #include #include #include #include #define _X86_ #include "windows.h" struct passargs { float a, a1[10]; long i, i1[10], l, l1[10]; } passargs; struct passargs pass; /* ** Prototype for DLL. Note the need for the __stdcall ** also, note that everything is passed by reference Last change: F 26 Jun 2000 3:20 pm */ int _stdcall dlla(struct passargs *pass); /*_declspec(dllimport) int _stdcall dlla(struct passargs *pass); */ int WINAPI WinMain() { long ido, result; result = dlla(&pass); if (result != 9999) { MessageBox(0, "", "Failed result", MB_OK | MB_SETFOREGROUND | MB_APPLMODAL); } if (fabs((float)(pass.a - 1.23)) > .1) { MessageBox(0, "", "failed a", MB_OK | MB_SETFOREGROUND | MB_APPLMODAL); } if (pass.i != 9876) { MessageBox(0, "", "Failed i", MB_OK | MB_SETFOREGROUND | MB_APPLMODAL); } if (pass.l == 0) { MessageBox(0, "", "failed l", MB_OK | MB_SETFOREGROUND | MB_APPLMODAL); } for (ido = 0; ido < 10; ido++) { if (fabs((float)(pass.a1[ido] - ((ido + 1) * 2 - 1))) > .1) { MessageBox(0, "", "Failed a1", MB_OK | MB_SETFOREGROUND | MB_APPLMODAL); } if (pass.i1[ido] != ((ido + 1) * 2)) { MessageBox(0, "", "Failed i1: %d,%d", MB_OK | MB_SETFOREGROUND | MB_APPLMODAL); } if ((pass.l1[ido] & 1) == (ido & 1)) { /*even indices must be .TRUE., odd .FALSE.*/ MessageBox(0, "", "failed l1", MB_OK | MB_SETFOREGROUND | MB_APPLMODAL); } } /* when we get this far, everything is working */ MessageBox(0, "", "Passed Example 3", MB_OK | MB_SETFOREGROUND | MB_APPLMODAL); return (0); }