I'm trying to get a reference to a class inside my dll, from main.cpp.
I'm using this tutorial to do it.
The problem is with the client code,
specifically with this part:Code://============================================================ //Client code //How to load the interface and call functions GETINTERFACE pfnInterface=0; //pointer to GetMyInterface function I_MyInterface * pInterface =0; //pointer to MyInterface struct HINSTANCE hMyDll = ::LoadLibrary("myinterface.dll"); if(hMyDll != NULL) { //Get the functions address pfnInterface= (GETINTERFACE)::GetProcAddress(hMyDll,"GetMyInterface"); //Release Dll if we werent able to get the function if(pfnInterface == 0) { ::FreeLibrary(hMyDll); return; } //Call the Function HRESULT hr = pfnInterface(&pInterface); //Release if it didnt work if(FAILED(hr)) { ::FreeLibrary(hMyDll); return; } //Interface was loaded, we can now call functions pInterface->Init(1); pInterface->DoStuff(); pInterface->Release(); //How to release the interface FREEINTERFACE pfnFree = (FREEINTERFACE )::GetProcAddress(hMyDll,"FreeMyInterface"); if(pfnFree != 0) pfnFree(&hMyDll); //Release the DLL if we dont have any use for it now ::FreeLibrary(hMyDll); }
I get a bunch of errors because GETINTERFACE isn't declared anywhere (except inside the DLL).Code:GETINTERFACE pfnInterface=0; //pointer to GetMyInterface function I_MyInterface * pInterface =0; //pointer to MyInterface struct
I'm not sure how to declare it, and I don't want to include the header for the dll because it has to be linked at run time and not at compile time. The tutorial left that part out.
Please let me know if you know how to declare GETINTERFACE. Thanks.



LinkBack URL
About LinkBacks



