How to open an exe inside a windows form C#

Asked

Viewed 1,439 times

2

I need to open a . exe inside a Windows form in C#, how to proceed with this. I already searched 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); 

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

1 answer

2

You need to create an instance of ProcessStartInfo and settar the property WindowStyle for Maximized.

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

Process.Start(startInfo);
  • So but if I put this code it does not present the . exe inside my Windows Forms and yes outside my main application.

  • Ah, I hadn’t read the whole question. I guess you won’t be able to do it so simply don’t.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.