将mshta带到前面 [英] Bring mshta to front
问题描述
我有一个应用需要将mshta中托管的第三方应用程序带到前面。
我'到目前为止,我已经尝试了下面的运气。
  [DllImport(" User32.dll")]
$
      private static extern bool SetForegroundWindow(IntPtr hWnd);
      [System.Runtime.InteropServices.DllImport(" User32.dll")]
$
      private static extern bool ShowWindow(IntPtr handle,int nCmdShow);
      [System.Runtime.InteropServices.DllImport(" User32.dll")]
$
      private static extern bool IsIconic(IntPtr handle);
      [DllImport(" user32")]
$
      public static extern int BringWindowToTop(int hwnd);
甚至可以带 mshta .exe到前面?
mshta是一个应用程序,不是窗户。 您需要找到主窗口(考虑使用Process.GetProcessByName),然后您可以使用它来将窗口置于前面。 如果您找不到窗口句柄,则会出现问题。 请将
引用至
MSDN 关于使用SetForegroundWindow的限制。
Michael Taylor
http://blogs.msmvps.com/p3net
I have an application that needs to bring a third party application hosted in mshta to the front.
I've tried the following with no luck so far.
[DllImport("User32.dll")]
private static extern bool SetForegroundWindow(IntPtr hWnd);
[System.Runtime.InteropServices.DllImport("User32.dll")]
private static extern bool ShowWindow(IntPtr handle, int nCmdShow);
[System.Runtime.InteropServices.DllImport("User32.dll")]
private static extern bool IsIconic(IntPtr handle);
[DllImport("user32")]
public static extern int BringWindowToTop(int hwnd);
Is it even possible to bring mshta.exe to the front?
mshta is an application, not a window. You need to find the main window (consider using Process.GetProcessByName) and then you can use that to bring the window to the front. The issue will be if you cannot find the window handle. Refer to MSDN on the restrictions around using SetForegroundWindow however.
Michael Taylor
http://blogs.msmvps.com/p3net
这篇关于将mshta带到前面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!