Last active
July 4, 2022 14:38
-
-
Save AlexRasch/fd9f84371c0ba29b132d8da028ad4122 to your computer and use it in GitHub Desktop.
MessageBoxA
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.Runtime.InteropServices; // For Pinvoke & Win Api | |
namespace ConsoleApp1 | |
{ | |
internal class Program | |
{ | |
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Ansi)] | |
public static extern int MessageBoxA(IntPtr hWnd, String text, String caption, uint type); | |
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)] | |
public static extern int MessageBoxW(IntPtr hWnd, String text, String caption, uint type); | |
static void Main(string[] args) | |
{ | |
// Does not display correct | |
MessageBoxA(IntPtr.Zero, "фыфыфывы", "фывыфыв", 0); | |
// Displays the chars correct notice the W and CharSet difference | |
MessageBoxW(IntPtr.Zero, "фыфыфывы", "фывыфыв", 0); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment