Page 1 of 1

wxDynamicLibrary and class

Posted: Wed May 24, 2006 5:20 pm
by DeadSinn
HI, i have a little question xD
I Maked a DLL and inside that i have got a class : "DllClass".
I maked it without problem, but when i want call the class member/function i dont know how i can do this.

Code: Select all


typedef DllClass* (* DllClass_v)(void); 
wxDynamicLibrary dyn;

if( dyn.Load (LIB_NAME, wxDL_VERBATIM) )
{ 
    wxMessageBox ( _T ("#Worked") , _T("DLL LOaded") , wxICON_INFORMATION | wxOK ) ;
}
else
{
    wxMessageBox ( _T ("#ARgh, i cant open it") , _T("DLL Error") , wxICON_INFORMATION | wxOK ) ;
}

wxDYNLIB_FUNCTION ( DllClass_v , CreateTest , dyn ) ;

if ( ! pfnCreateTest )
{
    wxMessageBox ( _T ( "NO FUNCTION" ) , _T ( "NO FUNCTION" ) , wxICON_INFORMATION | wxOK ) ;
}
else
{
    wxMessageBox ( _T ( "FUNCTION" ) , _T ( "FUNCTION" ) , wxICON_INFORMATION | wxOK ) ;
                
}
With this code, i know ( i thing ) thath inside "pfnCreateTest" there is the class , but, How i can use this ?
DLL CODE

Code: Select all

BOOL APIENTRY DllMain( HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved )
{
return TRUE;
}

extern "C" __declspec (dllexport) DllClass* CreateTest()
{
    //Nothing
}

Thanks

Posted: Thu May 25, 2006 7:43 am
by Cursor
Do I understand correctly ?
You want to create a dll with a class implementation. You want to load this dll at runtime, create an instance of this class (by a factory function) and call functions from this instance from the main program ?

If it is that, you must declare the class prototype (or at least the interface of your class) in order to precise what function the compiler must envisage.