I have successfully loaded a MANAGED C++ dll from an UNmanaged C++ program. I can even manage to call methods in classes in that
DLL. What I need to know is how to pass a string back to the UNmanaged code from the managed code.
public __gc __interface KMS::Transport::Managed::IManager
{
public:
virtual int Initialize (HRESULT *result, [System::Runtime::InteropServices::Out] String *error_text) = 0;
};
public __gc class KMS::Transport::Managed::Manager: public IManager
{
public:
Manager (void)
{
}
int Initialize (HRESULT *result, [System::Runtime::InteropServices::Out] String *error_text)
{
*result = S_OK;
// how do I set the value of error_text here
}
}
-------------------------------------------
Roy Chastain
KMSystems, Inc.
Well, I found something that appears to work.
Change the signature of the Initialize method to use .... String **error_text instead of String *error_text
Then *error_text = new String("Hello");
The unmanaged code looks like
int ret_val
BSTR msg = _bstr_t(LPVOID(NULL));
HRESULT result1;
result = manager->Initialize(&result1,&msg,&ret_val);
wprintf(LPWSTR(msg));
SysFreeString(msg);
>I have successfully loaded a MANAGED C++ dll from an UNmanaged C++ program. I can even manage to call methods in classes in that
>DLL. What I need to know is how to pass a string back to the UNmanaged code from the managed code.
[quoted text clipped - 22 lines]
>Roy Chastain
>KMSystems, Inc.
-------------------------------------------
Roy Chastain
KMSystems, Inc.