Open Win32 App in C#, with extern keyword

来源:互联网 发布:原生js获取json文件 编辑:程序博客网 时间:2024/04/30 08:12

Process _winMergeProc = Process.Start("WinMerge", args);

BringProcessToFront(_winMergeProc);

        

----

const int SW_RESTORE = 9;



        private static void BringProcessToFront(Process process)


        {
            var hWnd = process.MainWindowHandle;
            if (IsIconic(hWnd))
                ShowWindow(hWnd, SW_RESTORE);
            SetForegroundWindow(hWnd);
        }


        [DllImport("User32.dll")]
        private static extern bool SetForegroundWindow(IntPtr handle);
        [DllImport("User32.dll")]
        private static extern bool ShowWindow(IntPtr handle, int nCmdShow);
        [DllImport("User32.dll")]
        private static extern bool IsIconic(IntPtr handle);

0 0