Hello,
I've got a C++ dll that I need to call that returns a char* value. I've tried using this in C#, but I can't seem to get it to work. This is the way I'd like to do it, but my string is always blank.
[DllImport("stringReturn.dll"
]
public static extern string GiveMeMyString();
Here is the call in my C# code (I always get an error):
MessageBox.Show(GiveMeMyString());
In my C++ dll I have a CString that I convert and return. If I set myString equal to a constant then it works.
myString = myCString.GetBuffer(myCString.GetLength());
return myString;
Any thoughts? Thanks for any help, I really appreciate it.
Thanks,
Nick
I've got a C++ dll that I need to call that returns a char* value. I've tried using this in C#, but I can't seem to get it to work. This is the way I'd like to do it, but my string is always blank.
[DllImport("stringReturn.dll"
public static extern string GiveMeMyString();
Here is the call in my C# code (I always get an error):
MessageBox.Show(GiveMeMyString());
In my C++ dll I have a CString that I convert and return. If I set myString equal to a constant then it works.
myString = myCString.GetBuffer(myCString.GetLength());
return myString;
Any thoughts? Thanks for any help, I really appreciate it.
Thanks,
Nick