How can I send a managed object to native function to use it?
How can I send a managed object to native function to use it? void managed_function() { Object^ obj = gcnew Object(); void* ptr = obj ??? // How to convert Managed object to void*? unmanaged_function(ptr); } // The parameter type should be void* and I can not change the type. // This function is native but it uses managed object. Because type of ptr could not be // Object^ I called it "Unmanaged Function". void unmanaged_function(void* ptr) { Object^ obj = ptr ??? // How to convert void* to Managed object? obj->SomeManagedMethods(); } The cleaner and the better approach is to use gcroot