프로그래밍/.NET2012. 7. 26. 13:26


핸들값을 찾는 예제


이벤트 메세지 보내기

SendMessage(int hwnd, int wMsg, int wParam, int lParam)

인자값 : 이벤트를 보낼 핸들값, 이벤트 메세지, 그에 따른 부수적인 메세지들)


C# 소스

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;

namespace SandMessage
{
    class Program
    {
        [DllImport("user32.dll")]
        public static extern int FindWindow(string lpClassName, string lpWindowName);
        [DllImport("user32.dll")]
        public static extern int SendMessage(int hwnd, int wMsg, int wParam, int lParam);

        [STAThread]
        static void Main(string[] args)
        {
            // 시작메뉴 핸들값 찾아서 저장
            int hw = FindWindow("Button", "시작");

            const int WM_CLICK = 0x00F5;

            SendMessage(hw, WM_CLICK, 0, 1);
        }
    }
}


실행하시면 시작 메뉴가 열리고 닫히는 걸 보실 수 있습니다.


'프로그래밍 > .NET' 카테고리의 다른 글

프로퍼티 SET/GET  (0) 2012.08.01
DB 연결(오라클 10g)  (0) 2012.07.30
핸들값  (0) 2012.07.26
Alert창  (0) 2012.07.25
이미지 크기 변환  (0) 2011.10.07
Posted by 건깡