흠.. 일반적으로 닷넷에서 정해진 폼이 있다. 하지만 원하는 메세지들 내용 등을 바꾸자면 아래 예제 코드와 같이 가능하다.

*예제 코드*

public class MessageBoxChange
    {
        delegate int HookProc(int code, IntPtr wParam, IntPtr lParam);

        [DllImport("user32.dll", SetLastError = true)]
        static extern IntPtr SetWindowsHookEx(int hook, HookProc callback, IntPtr hMod, uint dwThreadId);

        [DllImport("user32.dll")]
        static extern bool UnhookWindowsHookEx(IntPtr hhk);

        [DllImport("user32.dll")]
        static extern int CallNextHookEx(IntPtr hhk, int nCode, IntPtr wParam, IntPtr lParam);

        [DllImport("user32.dll")]
        static extern IntPtr GetDlgItem(IntPtr hDlg, DialogResult nIDDlgItem);

        [DllImport("user32.dll")]
        static extern bool SetDlgItemText(IntPtr hDlg, DialogResult nIDDlgItem, string lpString);

        [DllImport("kernel32.dll")]
        static extern uint GetCurrentThreadId();

        static IntPtr g_hHook;

         string yes;
         string no;

        //OK
        public DialogResult Show(string text, string caption, string ok)
        {
            this.yes = yes;
            this.no = no;
            g_hHook = SetWindowsHookEx(5, new HookProc(HookWndProc), IntPtr.Zero, GetCurrentThreadId());
            return MessageBox.Show(text, caption, MessageBoxButtons.OK, MessageBoxIcon.Question);
        }

        //YES NO
        public DialogResult Show(string text, string caption, string yes, string no)
        {
            this.yes = yes;
            this.no = no;
            g_hHook = SetWindowsHookEx(5, new HookProc(HookWndProc), IntPtr.Zero, GetCurrentThreadId());
            return MessageBox.Show(text, caption, MessageBoxButtons.YesNo, MessageBoxIcon.Question);
        }

        public int HookWndProc(int nCode, IntPtr wParam, IntPtr lParam)
        {
            IntPtr hChildWnd;

            if (nCode == 5)
            {
                hChildWnd = wParam;

                if (GetDlgItem(hChildWnd, DialogResult.OK) != null)
                    SetDlgItemText(hChildWnd, DialogResult.OK, this.yes);

                if (GetDlgItem(hChildWnd, DialogResult.Yes) != null)
                    SetDlgItemText(hChildWnd, DialogResult.Yes, this.yes);

                if (GetDlgItem(hChildWnd, DialogResult.No) != null)
                    SetDlgItemText(hChildWnd, DialogResult.No, this.no);

                UnhookWindowsHookEx(g_hHook);
            }
            else
                CallNextHookEx(g_hHook, nCode, wParam, lParam);

            return 0;
        }
    }

당연히 주의해야할 점은 네임스페이스다.

이들은 Forms를 참조하는 다이얼로그와 P-INVOKE를 이용하기 위한 InteropServices 의 네임스페이스를 참조해야한다.

이를 꼭 명심하자!!

[C#]API 사이트 C# 2008. 12. 26. 14:49
http://www.pinvoke.net/

P-INVOKE -_- 이놈 땜시 고생했던 기억이 생각난다..

저기 가면 API가 많다는.. 모두 즐거운 프로그래밍!!