C
C#2y ago
Silme94

user32.dll how to add icon on message box

how to add icon on user32.dll msgbox?
using System;
using System.Runtime.InteropServices;

class Program{

[DllImport("user32.dll", CharSet = CharSet.Unicode)]
public static extern int MessageBox(IntPtr hW, String content, String title, uint type);
public static string text;
public static string argument;
static void Main(string[] args){
for (int i = 0; i < args.Length; i++)
{
argument = argument + " " + args[i];
}
text = argument;
MessageBox(new IntPtr(0), text, "Error", 0);
}
}
using System;
using System.Runtime.InteropServices;

class Program{

[DllImport("user32.dll", CharSet = CharSet.Unicode)]
public static extern int MessageBox(IntPtr hW, String content, String title, uint type);
public static string text;
public static string argument;
static void Main(string[] args){
for (int i = 0; i < args.Length; i++)
{
argument = argument + " " + args[i];
}
text = argument;
MessageBox(new IntPtr(0), text, "Error", 0);
}
}
2 Replies
undisputed world champions
if you set TargetFramework to net6.0-windows and UseWPF to true in your *csproj:
<TargetFramework>net6.0-windows</TargetFramework>
<UseWPF>true</UseWPF>
<TargetFramework>net6.0-windows</TargetFramework>
<UseWPF>true</UseWPF>
you can use
using System.Windows;

MessageBox.Show("text", "caption", MessageBoxButton.OK, MessageBoxImage.Question);
using System.Windows;

MessageBox.Show("text", "caption", MessageBoxButton.OK, MessageBoxImage.Question);
there are a couple of options for MessageBoxImage (and MessageBoxButton)
Silme94
Silme942y ago
alr thanks