I\'m attempting to call the following trivial C function from C#:
SIMPLEDLL_API const char* ReturnString()
{
return \"Returning a static string!\";
}
In my P/Invoke experience, you usually have 2 parameters: 1. a pre-allocated buffer in, and 2, the length of the buffer. The Return value is the length of data returned (not to exceed the original length).
Usually the DEBUG releases won't move memory around as much.
BTW, You can pass in a pre-allocated StringBuilder, then set sb.Lenght = the return value of the C function, then you won't have a bunch of \0 nulls at the end of your string.