I have a dll written in C ++. The function of this DLL is similar to the following code:
C ++ Code:
char _H *GetPalette() {
-------Functions body
-------Functions body
return pPaletteString;
}
Now I want to get a pallet string from this GetPalette () function in C # code.
How can I get a string from this function? I 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 a line like this
IntPtr result;
result = imgProcess.GetPallet();
string pallet;
pallet = Marshal.PtrToStringAnsi(result);
MessageBox.Show(pallet);
This code does not work correctly. Can any plz body help me, How can I get a string value from my C ++ DLL function?
thank
Shahriar
source
share