将计算器放在TopMost C#上

时间:2016-08-17 16:16:05

标签: c# windows api

我正在做一个应用程序,它将启动例如MS Word,MS Powerpoint,记事本和计算器。
为此,我使用了SetWindowPos API,它适用于所有人,除了计算器 这是我做的:

[DllImport("user32.dll")]
private static extern bool ShowWindow(IntPtr hWnd, uint windowStyle);

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

private void LaunchOnTop(string processPath)
{
    Process process = new Process();

    process.StartInfo.FileName = processPath;
    process.Start();
    process.WaitForInputIdle();

    if (process != null)
    {
        ShowWindow(process.MainWindowHandle, 1u);
        SetWindowPos(process.MainWindowHandle, new IntPtr(-1), 0, 0, 0, 0, 3u);                
    }
}

0 个答案:

没有答案