試試這個(在C#它):從this site服用。
internal class Program
{
[DllImport("user32.dll", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool SetWindowPos(IntPtr hWnd,
int hWndInsertAfter, int x, int y, int cx, int cy, int uFlags);
private const int HWND_TOPMOST = -1;
private const int SWP_NOMOVE = 0x0002;
private const int SWP_NOSIZE = 0x0001;
public static void Main()
{
Process process = Process.Start(@"notepad.exe", "");
if (null != process)
{
SetWindowPos(process.MainWindowHandle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
}
}
}
您需要調用SetForegroundWindow()。獲得你需要的窗口處理應該是相當具有挑戰性的。當Windows拒絕請求時它也不起作用,因爲它檢測到用戶正在使用另一個窗口。你不能把窗戶推到用戶的臉上。 –