I would like to open process in within my windows form application.
For example I would like when a user press on button in one of the windows form container the mstsc.exe will open.
And if he will press on the button it will open IE on another container,
[DllImport("user32.dll", SetLastError = true)]
static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);
private void button1_Click(object sender, EventArgs e)
{
Process p = Process.Start("mstsc.exe", @"c:\VPN4.rdp");
Thread.Sleep(3000);
p.StartInfo.CreateNoWindow = true; // new
SetParent(p.MainWindowHandle, this.panel1.Handle);
p.StartInfo.WindowStyle = ProcessWindowStyle.Maximized; //new
}
It open the process but not in the windows form ,,,