How did you declare your PInvoke signature?
If you modify the string pointed to by char*, you have to pass a
StringBuilder with sufficient size to hold the new string + terminating
null.
Else you can pass a System.String.
Note that you need to help the interop marshaler a bit when your native code
is a UNICODE build, by applying the MarshalAs(UnmanagedType.LPWStr)]
attribute to the argument.
(...., [In,Out, MarshalAs(UnmanagedType.LPWStr)]StringBuilder s)
else the interop marshaler converts wide-char strings to multi-byte by
default.
(...., [In,Out]StringBuilder s)
Willy.
"Jason Bell" <ha*********@yahoo.com> wrote in message
news:Xn*********************************@198.161.1 57.145...
I'm an experienced programmer, but a newbie to c#, so please be kind :)
In a c++, unmanaged, DLL of my own making I have a function called
void XGL_Core_SetCaption(XGL_Core * core, char * caption);
Using DLLImport I've gotten all functions working except for the ones
requiring char * . Anyone care to inform me how to pass the contents of a
c# string to this c++ function? I've tried passing string and char[],
with
no luck.
Any thoughts?