Hey guys,
I'm new to C++. I'm calling a C++ function from C# using a PINVOKE and wanting to get a string back as an out parameter. However I just get an empty string back. The int out parameter works fine.
Importing:
[DllImport ( @"UnamanagedAssembly.dll", CharSet = CharSet.Ansi)]
public static extern int Activate(ref int numActivated, StringBuilder eventsActivated);
extern "C" __declspec(dllexport) int Activate(int *p_NumActivated, char *p_EventsActivated) {return Activation::GetInstance()->Activate(p_NumActivated, p_EventsActivated);}
Calling my C++ function from C#:
int numActivated = 0;
StringBuilder eventsActivated = new StringBuilder();
int status = Activate(ref numActivated, eventsActivated);
The C++ function:
int Activation::Activate(int *p_NumActivated, char *&p_EventsActivated)
{
char *pTemp = "Hello";
p_EventsActivated = pTemp;
*p_NumActivated = 1;
return 0;
}