
Untitled
By: a guest on
Apr 27th, 2012 | syntax:
None | size: 0.78 KB | hits: 15 | expires: Never
Encoding from C to C#
extern "C" RETURNCHAR_API char* testString()
{
return test;
}
extern "C" RETURNCHAR_API char* __cdecl testString();
public static class ImportTest
{
[DllImport("ReturnChar.dll", EntryPoint = "testString", CallingConvention = CallingConvention.Cdecl)]
public static unsafe extern char* testString();
}
public partial class MainWindow : Window
{
public unsafe MainWindow()
{
InitializeComponent();
try
{
StringBuilder sb = new StringBuilder(new string(ImportTest.testString()));
textBox1.Text = sb.ToString();
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}