IntPtr hwnd = ((HwndSource)PresentationSource.FromVisual(this)).Handle;
//句柄
public void CmdPing()
{ Process p = new Process(); IntPtr hwnd = ((HwndSource)PresentationSource.FromVisual(this)).Handle; p.StartInfo.FileName = "cmd.exe "; p.Start(); System.Threading.Thread.Sleep(150); SetParent(p.MainWindowHandle, hwnd); ShowWindow(p.MainWindowHandle, 3); }