[SOLVED]Import class/struct from a DLL?
Posted: Mon Dec 13, 2010 12:20 pm
I just need to know how to import a class and struct from a DLL, so far I can import a function just fine,
This is the code I have
This is the code I have
Code: Select all
#include <windows.h>
#include <iostream.h>
#include <stdio.h>
#include <conio.h>
#define MAXMODULE 50
#define DLL_IMPORT_EXPORT
typedef void (WINAPI*cfunc)();
cfunc TestModule;
int main() {
HINSTANCE hLib=LoadLibrary("SPINELESSAPI.DLL");
if(hLib==NULL) {
cout << "Unable to load library!" << endl;
getch();
return 1;
}
char mod[MAXMODULE];
GetModuleFileName((HMODULE)hLib, (LPTSTR)mod, MAXMODULE);
cout << "Library loaded: " << mod << endl;
TestModule=(cfunc)GetProcAddress((HMODULE)hLib, "TestModule");
if((TestModule==NULL) )//|| (TestRect==NULL))
{
cout << "Unable to load function(s)." << endl;
FreeLibrary((HMODULE)hLib);
return 1;
}
TestModule();
SRECTANGLE Rectangle; //--This line right here doesn't work, and I can't figure out why...--//
FreeLibrary((HMODULE)hLib);
getch();
return 0;
}