/* main1.c, This is a main program unit for use with the */ /* DLL1 DLL. Please refer to the MK1_CF.BAT */ /* file for instruction on building this example */ /* This example demonstrates 'simple' interfaces between */ /* DLL and MAIN, using intrinsic data types */ #include #include #include #include #include #include #include #include #include #include #include #define _X86_ #include "windows.h" /* ** Prototype for DLL. Note the need for the __stdcall ** also, note that everything is passed by reference */ int _stdcall dll1(float *a, float *a1, long *i, long *i1, long *l, long *l1); /*_declspec(dllimport) int _stdcall dll1(float *a, float *a1, long *i, long *i1, long *l, long *l1); */ /*int WINAPI WinMain(HANDLE hInstance, HANDLE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)*/ int WINAPI WinMain() { float a; float a1[10]; long i; long i1[10]; long l; long l1[10]; long ido, result; result = dll1(&a, &a1[0], &i, &i1[0], &l, &l1[0]); if (result != 9999) { MessageBox(0, "", "Failed result", MB_OK | MB_SETFOREGROUND | MB_APPLMODAL); } if (fabs((float)(a - 1.23)) > .1) { MessageBox(0, "", "failed a", MB_OK | MB_SETFOREGROUND | MB_APPLMODAL); } if (i != 9876) { MessageBox(0, "", "Failed i", MB_OK | MB_SETFOREGROUND | MB_APPLMODAL); } if (l == 0) { MessageBox(0, "", "failed l", MB_OK | MB_SETFOREGROUND | MB_APPLMODAL); } for (ido = 0; ido < 10; ido++) { if (fabs((float)(a1[ido] - ((ido + 1) * 2 - 1))) > .1) { MessageBox(0, "", "Failed a1", MB_OK | MB_SETFOREGROUND | MB_APPLMODAL); } if (i1[ido] != ((ido + 1) * 2)) { MessageBox(0, "", "Failed i1: %d,%d", MB_OK | MB_SETFOREGROUND | MB_APPLMODAL); } if ((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 1", MB_OK | MB_SETFOREGROUND | MB_APPLMODAL); return (0); }