#include #include #include #include #define DllExport __declspec(dllexport) #define DllImport __declspec(dllimport) typedef void (CALLBACK* dllfunc)(char *); int main (int argc, char *argv[]) { HINSTANCE h; dllfunc func; // Function pointer if (argc < 3) { fprintf (stderr, "Usage: %s library string\n", argv[0]); return EXIT_FAILURE; } /* Open the library */ h = LoadLibrary (argv[1]); if (h == NULL) { fprintf (stderr, "Unable to open library %s\n", argv[1]); return EXIT_FAILURE; } /* Find the library function */ func = (dllfunc) GetProcAddress(h, "dllfunc"); if (func == NULL) { fprintf (stderr, "Unable to find function dllfunc in library %s\n", argv[1]); FreeLibrary (h); } /* Call the library function */ func (argv[2]); /* Close the library */ FreeLibrary (h); return EXIT_SUCCESS; } DllExport void reverse_string (char *s) { register int i, length = strlen (s); for (i = 0; i < length - i - 1; i++) { char temp = s[i]; s[i] = s[length - i - 1]; s[length - i - 1] = temp; } }