Are you asking how to dynamically load a DLL into your program? If so, here is an example piece of code I wrote for a friend.
#include <windows.h>
#include <iostream>
using namespace std;
//This makes the function pointers easier
typedef int (__cdecl *DLLCALL)();
int main()
{
HINSTANCE library;
DLLCALL testing = NULL;
////This here loads the DLL and points the library HINSTACE to it
library = LoadLibrary("dlltest.dll");
////This makes sure it loaded correctly. If it did, then library shouldn't equal NULL. It will continue onward.
if(library != NULL)
{
////This is the function that gets the function named "testing" out of the DLL. It "stores" it in the variable
////I created at the top of the main function, testing.
testing = (DLLCALL) GetProcAddress(library, "testing");
////If the function loaded correctly, run this code.
if(testing != NULL)
{
////The "testing" function i created in the DLL code just returns 100. So, this will print 100.
cout << testing();
}
////Unload the library.
FreeLibrary(library);
}
}
It uses a simple testing DLL I wrote that contains a function named testing() that simply returns 100
Edited by mebob, 07 December 2011 - 02:26 PM.