I have a DLL file which has a class called trial and it contains a function called test, I have another project in which I loaded the DLL using the loadlibrary function from the windows module, now I want to know how to create an object of type trial in the new project.
I tried defining the class as "class __declspec(dllexport) trial" but I don't know how to create an object in the main file now.
Trail.h is as follows:
class __declspec(dllexport) TRIALSHARED_EXPORT Trial
{
public:
Trial();
void test();
};
Trail.cpp is as follows:
extern "C"{
Trial::Trial(){
cout<<"object is created"<<endl;
}
void Trial:: test(){
cout<<"dynamic thingy"<<endl;
}
}
The main function is as follows:
int main()
{
HINSTANCE here=LoadLibrary(L"C:\\Users\\vinay\\Documents\\qt c++\\build-trial-Desktop_Qt_5_12_0_MinGW_64_bit-Debug\\debug\\trial.dll");
if(!here){
cout<<"could not load the lib"<<std::endl;
}
else{
cout<<"library loaded"<<endl;
typedef void(*FNPTR)();
FNPTR fn=FNPTR(GetProcAddress(here,"Trial"));
fn();
}
}