如何确保的Process.Start(的ProcessStartInfo)推出了工艺窗口拥有所有形式重点是什么? [英] How to ensure process window launched by Process.Start(ProcessStartInfo) has focus of all Forms?

查看:441
本文介绍了如何确保的Process.Start(的ProcessStartInfo)推出了工艺窗口拥有所有形式重点是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

C#。如何确保的Process.Start(的ProcessStartInfo)推出了工艺窗口拥有所有形式重点是什么?
谢谢,

c#.How to ensure process window launched by Process.Start(ProcessStartInfo) has focus of all Forms? Thanks,

推荐答案

SetForegroundWindow 的使用等方法重点设置有很多限制。如果你真的希望确保,即启动过程将接收焦点,我建议您使用以下本机(非托管)功能

Usage of SetForegroundWindow and other methods of setting of focus has a lot of restrictions. If you really want to be sure, that the started process will receive focus I recommend you to use following native (unmanaged) functions

SystemParametersInfo (SPI_GETFOREGROUNDLOCKTIMEOUT, 0, (PVOID)&dwLockedTimeout, 0);
SystemParametersInfo (SPI_SETFOREGROUNDLOCKTIMEOUT, 0, (PVOID)0,
                      SPIF_SENDWININICHANGE | SPIF_UPDATEINIFILE);

在流程启动和恢复

SystemParametersInfo (SPI_SETFOREGROUNDLOCKTIMEOUT, 0, (PVOID)&dwLockedTimeout,
                      SPIF_SENDWININICHANGE | SPIF_UPDATEINIFILE);



在最后。 ;像

at the end. A call like

WaitForInputIdle (pi.hProcess, 5000);



程序开始后和 SPI_SETFOREGROUNDLOCKTIMEOUT 可也是有帮助的,如果你将不得不立即

after the program start and before restoring of SPI_SETFOREGROUNDLOCKTIMEOUT can be also helpful if you will have problems with immediate

这篇关于如何确保的Process.Start(的ProcessStartInfo)推出了工艺窗口拥有所有形式重点是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆