GLProgramming.com

home :: about :: development guides :: irc :: forums :: search :: paste :: links :: contribute :: code dump

-> Click here to learn how to get live help <-


New Paste :: Recent Pastes:: No Line Numbers


DLL Loading by Merlin
1
 
#include <windows.h>

typedef void (*DLL_WRITETEXT)(char*);

int main() {
    char message[] = "Hello again...";
    HINSTANCE hInst = NULL;
    hInst = LoadLibrary("test.dll");
    if (hInst == NULL) {        
        MessageBox(NULL, "Error loading DLL.", "Error", MB_OK | MB_ICONERROR);
        return 0;
    }
    else {
        DLL_WRITETEXT WriteText = NULL;
        WriteText = (DLL_WRITETEXT)GetProcAddress(hInst, "WriteText");
        if (WriteText == NULL) {
            MessageBox(NULL, "Error loading function.", "Error", MB_OK | MB_ICONERROR);
            return 0;
        }
        else {
            WriteText(message);
        }
    }

    return 0;
}