How to open an exe inside a windows form C #

2

I need to open an .exe inside a Windows form in C #, how to proceed with it. I already researched the net and found the following example:

[DllImport("user32.dll", EntryPoint = "SetParent")]
public static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);

Process p = Process.Start(@"d:\TesteCS.exe"); 

Thread.Sleep(500);
SetParent(p.MainWindowHandle, panel1.Handle); 

.exe opens but stays the exact size of it and needs to be maximized.

    
asked by anonymous 17.03.2016 / 20:13

1 answer

2

You need to create an instance of ProcessStartInfo and set property WindowStyle to Maximized .

var startInfo = new ProcessStartInfo(@"d:\TesteCS.exe");
startInfo.WindowStyle = ProcessWindowStyle.Maximimized;

Process.Start(startInfo);
    
17.03.2016 / 20:18