I've a DLL written in C++. A function of this DLL is like the following code:
C++ code:
char _H *GetPalette() {
-------Functions body
-------Functions body
return pPaletteString;
}
Now I want to get the Pallet String from that GetPalette() function in C# code.
How could I get string from that function? I've tried this in C# code. But could not get the correct result.
C# code:
[DllImport("cl.dll", EntryPoint = "GetPalette@0", CallingConvention = CallingConvention.StdCall)]
private static extern IntPtr libGetPalette();
public IntPtr GetPalette()
{
return libGetPalette();
}
Finally I want to get string like this
IntPtr result;
result = imgProcess.GetPallet();
string pallet;
pallet = Marshal.PtrToStringAnsi(result);
MessageBox.Show(pallet);
This code does not work properly. Can some body plz help me, How could I get the string value from my C++ DLL function?
Thanks
Shahriar