Created
March 19, 2023 06:28
-
-
Save un4ckn0wl3z/580e791d6ef8a1806b0cb613376fa33a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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