Calling COM wrapped c# dll from unmanaged c++: how to pass a 'string' and retrieve an updated value
I use COM interop to call functions in a c# dll from my VC6 MFC DLL, and this works fine.
I want to call a function to retrieve string values. How do I declare a 'string' in my unmanaged C++? How should the 'string' appear in the开发者_如何学Python c# code? Currently the c# function in the dll takes ref string arguments, and my c# test app works fine, but what do I pass from an unmanaged c++ call?Hope this makes sense. Any help welcome, Thanks.
Problem solved.
I create a BSTR variable in my VC6 code:
BSTR key = SysAllocString(NULL);
I call my C# assembly:
presenter->GetObject(&key);
My C# function is:
void GetObject(ref string key);
:)
精彩评论