Skip to content

Instantly share code, notes, and snippets.

@un4ckn0wl3z
Created March 19, 2023 06:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save un4ckn0wl3z/6a1cd3c55616e6923cffebaa92790d36 to your computer and use it in GitHub Desktop.
Save un4ckn0wl3z/6a1cd3c55616e6923cffebaa92790d36 to your computer and use it in GitHub Desktop.
using System;
using System.Runtime.InteropServices;
using DInvoke.DynamicInvoke;
namespace ConsoleApp1
{
internal class Program
{
[UnmanagedFunctionPointer(CallingConvention.StdCall, CharSet = CharSet.Unicode)]
delegate int MessageBoxW(IntPtr hWnd, string lpText, string pCaption, uint uType);
static void Main(string[] args)
{
var parameters = new object[] { IntPtr.Zero, "My first D/Invoke!", "Hello World", (uint)0 };
Generic.DynamicAPIInvoke("user32.dll", "MessageBoxW", typeof(MessageBoxW), ref parameters);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment