class A{ public: int LocalValue; int *LocalPointer; static int StaticValue; static int *StaticPointer; }; class B{ public: int LocalValue; int *LocalPointer; };
dll側 class CTest{public: int LocalValue; int *LocalPointer; static int StaticValue; static int *StaticPointer; }; int CTest::StaticValue = 0; int* CTest::StaticPointer = NULL; #define EXPORT extern "C" __declspec(dllexport) EXPORT int TestFunction1(class CTest *test){ return 0; }
exe側 dll側と同じCTestの定義
typedef int (*LPDLLFUNC1)(class CTest*); int main(){ HINSTANCE hDll; LPDLLFUNC1 lpDllFunc1; hDll = LoadLibrary("dll.dll"); lpDllFunc1 = (LPDLLFUNC1)GetProcAddress(hDll, "TestFunction1");
class CTest test; test.LocalValue= 100; test.StaticValue= 200; test.LocalPointer= new int; *(test.LocalPointer)= 1000; test.StaticPointer= new int; *(test.StaticPointer)= 2000;