Skip to content

Instantly share code, notes, and snippets.

@fero23
Created November 17, 2015 21:57
Show Gist options
  • Save fero23/fb47c02cca0d20931b97 to your computer and use it in GitHub Desktop.
Save fero23/fb47c02cca0d20931b97 to your computer and use it in GitHub Desktop.
using System;
using System.Runtime.InteropServices;
using System.Windows.Forms;
namespace HSTest
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
hs_init(IntPtr.Zero, IntPtr.Zero);
}
[DllImport("formatter.so", CallingConvention = CallingConvention.Cdecl)]
private static extern void hs_init(IntPtr argc, IntPtr argv);
[DllImport("formatter.so", CallingConvention = CallingConvention.Cdecl)]
private static extern void hs_exit();
[DllImport("formatter.so", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
private static extern IntPtr format(string original);
private void button1_Click(object sender, EventArgs e)
{
textBox2.Text = Marshal.PtrToStringAnsi(format(textBox1.Text));
}
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
hs_exit();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment