Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static class ExportClass
- {
- [DllExport(ExportName = "SimpleFunction", CallingConvention = CallingConvention.StdCall)]
- public static int SimpleFunction(int a, int b)
- {
- return a + b;
- }
- [DllExport(ExportName = "CPPObjectMethodCall", CallingConvention = CallingConvention.StdCall)]
- public static bool CPPObjectMethodCall(IntPtr cppObject)
- {
- // How to make call of c++ object method here?
- }
- }
- class CPPClass
- {
- public :
- CPPClass() {}
- ~CPPClass() {}
- void CPPClassMethodCall(std :: string text)
- {
- MessageBoxA(NULL, text.c_str(), "Message", 0);
- }
- };
- void TestFunction()
- {
- HMODULE hDLL = LoadLibraryA("LibCS.dll");
- typedef int (*SIMPLEFUNCTION)(int a, int b);
- typedef bool (*CPPOBJECTMETHODCALL)(void * cppObject);
- SIMPLEFUNCTION SimpleFunction = (SIMPLEFUNCTION)GetProcAddress(hDLL, "SimpleFunction");
- CPPOBJECTMETHODCALL CPPObjectMethodCall = (CPPOBJECTMETHODCALL)GetProcAddress(hDLL, "CPPObjectMethodCall");
- int x = SimpleFunction(1, 2);
- CPPClass * cppObject = new CPPClass();
- // Pass pointer to C++ object
- CPPObjectMethodCall(cppObject);
- delete cppObject;
- FreeLibrary(hDLL);
- }
Add Comment
Please, Sign In to add comment