I'm calling the doThis
function in a .c
file in a Win32 DLL.
#include <stdio.h>
__declspec(dllexport) double doThis( char *message)
{
printf("do nothing much");
return 32.5;
}
using this calling code:
[DllImport(@"\\vmware-host\Shared Folders\c-sharp\Hot\MusicIO\Debug\HelloWorld.dll",
CallingConvention=CallingConvention.Cdecl)]
public static extern double doThis(string message);
private void button1_Click(object sender, EventArgs e)
{
double returned = doThis("what 2");
MessageBox.Show("Click " + returned);
}
That works fine, but I want the function to return a char *
... and return the message
variable.
When I change the doThis
to return a char *
, and the calling code to expect a string
, the Win32 Host crashes at runtime.
Any advice?
[weirdly, I think I had this working just before]