#include #include #include "TestInterface.h" // Simplified version of the logging function. void logOneLine (const char *clr, const char *msg) { static FILE *log = 0; log = fopen("TestDLL.log", log ? "at" : "wt"); fprintf (log, "%s: %s\n", clr, msg); fclose (log); } // Macro logging to ease reading the code. #define Log logOneLine(__func__, buff) int main (void) { char buff[255]; memset (buff, 0, 255*sizeof(char)); Log; HMODULE hDll = LoadLibrary(L"TestLib.dll"); while (1) { if (hDll) { // You might want to replace mangled names below with the right ones after compiling on your system. Instanciator instanciator = (Instanciator) GetProcAddress(hDll, "_Z11Instanciatebi"); Destructor destructor = (Destructor) GetProcAddress(hDll, "_Z7DestroyP13TestInterface"); if (!instanciator || !destructor) { sprintf (buff, "Unable to retrieve factory function pointers."); Log; break; } int numinstances = 0; printf ("\nEnter number of iterations:"); if (scanf("%d", &numinstances)!=1) break; sprintf (buff, "Number of iterations: %d.", numinstances); Log; if (numinstances<1 || numinstances > 40) break; TestInterface **ptrs = new TestInterface*[numinstances]; if (!ptrs) break; memset (ptrs, 0, sizeof(TestInterface*)*numinstances); for (int i=0; iget(bb, ii)) { sprintf(buff, "Got bb=%s, ii=%d.", bb ? "true" : "false", ii); Log; } } for (int i=0; i