Not too difficult! With the first dll, use LoadLibrary() to load the second dll.....then use GetProcAddress() to give you the function in the second dll....ala
Code:
//MyMain exe
#include <windows.h>
#define DllImport extern "C" __declspec (dllimport)
DllImport int LoadAndRun(void);
int WINAPI WinMain(HINSTANCE hThisInstance,
HINSTANCE hPrevInstance,
LPSTR lpszArgument,
int nFunsterStil){
LoadAndRun();
return 0;
}
Code:
//MyFirstDll.dll
//- use the library from this created to build the exe above
#include <windows.h>
#define DllExport extern "C" __declspec (dllexport)
typedef void (*MYDLLFUNC)(void);
DllExport int LoadAndRun(void){
HMODULE hMod;
MYDLLFUNC MyDllFunc = NULL;
hMod = LoadLibrary("MySecondDll.dll");
if(!hMod){
MessageBox(HWND_DESKTOP,"Error",NULL,MB_OK);
return 1;
}
MyDllFunc = (MYDLLFUNC)GetProcAddress(hMod,"FunctionInSecondDll");
if(!MyDllFunc){
MessageBox(HWND_DESKTOP,"Error",NULL,MB_OK);
return 1;
}
MyDllFunc();
FreeLibrary(hMod);
MyDllFunc = NULL;
return 0;
}
Code:
//MySecondDll.dll
// - Dont need the librarythat the compiler produces for this dll
#include <windows.h>
#define DllExport extern "C" __declspec (dllexport)
DllExport FunctionInSecondDll(void){
MessageBox(HWND_DESKTOP,"Got there in the end!!",NULL,MB_OK);
}