Quantcast
Channel: ClearScript
Viewing all articles
Browse latest Browse all 2297

New Post: calling native dll

$
0
0
Hi furesoft,

You can expose a .NET type with a P/Invoke method and invoke it from script. For example:
publicstaticclass Native
{
    [DllImport("user32.dll", CharSet = CharSet.Auto)]
    publicstaticexternint MessageBox(IntPtr hWnd, string text, string caption, int options);
}
and then
engine.AddHostType("Native", typeof(Native));
engine.AddHostType("IntPtr", typeof(IntPtr));
engine.Execute("Native.MessageBox(IntPtr.Zero, 'Hello!', 'Greetings', 0)");
Good luck!

Viewing all articles
Browse latest Browse all 2297

Latest Images

Trending Articles





Latest Images