Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@un4ckn0wl3z
Created March 19, 2023 06:28
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/580e791d6ef8a1806b0cb613376fa33a to your computer and use it in GitHub Desktop.
Save un4ckn0wl3z/580e791d6ef8a1806b0cb613376fa33a 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 address = Generic.GetLibraryAddress("user32.dll", "MessageBoxW");
var messageBoxW = (MessageBoxW)Marshal.GetDelegateForFunctionPointer(address, typeof(MessageBoxW));
messageBoxW(IntPtr.Zero, "Box 1", "Box 1", 0);
messageBoxW(IntPtr.Zero, "Box 2", "Box 2", 0);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment