, . EXE , , , :
Step 1: Create a wrapper API for your class, like this (probably don't compile, but you get the idea):
#define MYHANDLE unsigned int
__declspec(dllexport) MYHANDLE MyClassNewInstance() {
MyClass* ptr = new MyClass();
return (MYHANDLE)ptr;
}
__delspec(dllexport) MyClassDoSomething( MYHANDLE handle, int parm ) {
MyClass* ptr = (MyClass*)handle;
ptr->DoSomething(parm);
}
etc..
Step 2: To actually get the C functions from the EXE for use in the DLL, use the Win32 API functions GetModuleHandle () and GetProcAddress ().
Step 3. Create a proxy class in your DLL. Methods in the proxy class do nothing but call their C-function counterparts from EXE.
This will provide a βrealβ implementation of your class from the DLL. This is a hack, but it will probably work.
source
share