[英].net application is blocked on start hanging in process explorer with 1 MB
[英].net process start an Internet Explorer on top
我正在处理基于.NET Windows Form的应用程序产品。 在此应用程序中,我可以添加process.start以启动Internet Explorer会话。 但是,无论如何,IE会话总是在后台打开。 有没有一种方法可以迫使我在最终用户面前保持领先地位? 谢谢
没有直接的方法。 您必须使用pinvoke:
[DllImport("user32.dll", SetLastError = true)]
static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int x, int y, int cx, int cy, uint uFlags);
[Fact]
public void OpenIeAsTopWindow()
{
Process process = Process.Start("IExplore.exe", "http://google.com");
var HWND_TOPMOST = new IntPtr(-1);
const uint SWP_NOSIZE = 0x0001;
const uint SWP_NOMOVE = 0x0002;
const uint SWP_SHOWWINDOW = 0x0040;
SetWindowPos(process.MainWindowHandle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
}
所有的定义都来自这里
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.