从winform按钮打开应用程序或进程将其调整为特定位置

时间:2015-01-09 07:35:33

标签: c#

[DllImport("user32.dll", SetLastError = true)]
private static extern  bool MoveWindow(IntPtr hWnd, int x, int y, int width, int height, bool repaint);
private void button1_Click(object sender, EventArgs e)
{
     Process w = new Process();
     w.StartInfo = new ProcessStartInfo("explorer.exe");
     w.Start();
     Thread.Sleep(5000);
     w.WaitForInputIdle();

     bool ok = MoveWindow(w.MainWindowHandle, 0, 0, 100, 50, true);
     if (!ok) throw new System.ComponentModel.Win32Exception();

0 个答案:

没有答案