728x90
728x170

어떻한 특정 실행 파일을 항상 가장 위에 두고싶을때 사용 하는 방법이다.

찾아보니 특정 실행파일을 가장 상위로 올려주는 프로그램도 많이 있었다.

 

    class Program
    {
        static readonly IntPtr HWND_TOPMOST = new IntPtr(-1);
        static readonly IntPtr HWND_NOTOPMOST = new IntPtr(-2);

 

        const UInt32 SWP_NOSIZE = 0x0001;
        const UInt32 SWP_NOMOVE = 0x0002;

 

        [DllImport("user32.dll")]
        public static extern int BringWindowToTop(IntPtr hwnd);

 

        [DllImport("user32.dll")]
        [return: MarshalAs(UnmanagedType.Bool)]
        private static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int x, int y, int cx, int cy, uint uFlags);

 

        static void Main(string[] args)
        {
            System.Diagnostics.Process process = new System.Diagnostics.Process();
            process.StartInfo.FileName = @"C:\Program Files (x86)\Notepad2\Notepad2.exe";
            process.Start();
            process.WaitForInputIdle();
            BringWindowToTop(process.MainWindowHandle);
            SetWindowPos(process.MainWindowHandle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE);
        }
    }

728x90
그리드형

'C# > Winform' 카테고리의 다른 글

(.NET) 익명메서드를 이용한 간단 이벤트 처리  (0) 2017.04.15
(.NET) 확장 메서드  (0) 2017.04.15
(.NET) 문자열에서 숫자면 뽑아내기.  (0) 2017.04.15
(.NET) let  (0) 2017.04.15
(.NET) Converter, ConvertAll  (0) 2017.04.15
Posted by kjun
,