C# - 메시지 박스 띄우기


using System.Runtime.InteropServices;
class DllImport{

    [DllImport("User32.dll")]
    public static extern int MessageBox(int i, string text, string title, int type);
    
    public static void Main()   {
        MessageBox(0, "Messagebox test", "DllImport Test", 2);  
    }
}

 

사용자 삽입 이미지

광고

2개의 댓글

    • WIN32 API를 호출하여 사용하는 예제였는데요..
      XP SP3 에서는 .net framework 2.0으로 컴파일해도 정상적으로 되던데요..
      아래는 winform에서 테스트한 소스입니다.

      using System.Windows.Forms;
      using System.Runtime.InteropServices;

      namespace WindowsFormsApplication8
      {
      public partial class Form1 : Form
      {
      [DllImport("User32.dll")]
      public static extern int MessageBox(int i, string text, string title, int type);

      public Form1()
      {
      InitializeComponent();
      MessageBox(0, "Messagebox test", "DllImport Test", 2);
      }
      }
      }

댓글 남기기