Good day.

Here there was a similar question how on C # it is possible to implement the similar? And is it possible at all. An isolated application is being written, you need to run an exe file from under the terminal, where only this application is available. There will be a separate tab in which you need to launch a third-party application. Embed already written will not work, too difficult to rewrite.

thank you in advance for your response

  • one
    Do you mean the display of the console output of another program inside a window owned by a C # program? You can, in theory, for example, using WinAPI. Notice that not every program has a console or a window, so your task in general may not make sense. - VladD
  • Namely, a certain program in the program. Are there any links to this? I just do not understand how this can be implemented. Maybe examples. - VaLenOK007

2 answers 2

WinAPI will help

/// <summary> /// ΠŸΠΎΠ·Π²ΠΎΠ»ΡΠ΅Ρ‚ ΠΏΡ€ΠΈΠ²ΡΠ·Π°Ρ‚ΡŒ любой ΠΎΠ±ΡŠΠ΅ΠΊΡ‚ ΠΈΠΌΠ΅ΡŽΡ‰ΠΈΠΉ свой handle /// Π² качСствС Π΄ΠΎΡ‡Π΅Ρ€Π½ΠΎΠ³ΠΎ ΠœΠ”Π˜-ΠΎΠΊΠ½Π° /// </summary> /// <param name="hWndChild">ДСскриптор привязываСмого ΠΎΠΊΠ½Π°</param> /// <param name="hWndNewParent">ДСскриптор ΠΊΡƒΠ΄Π° привязываСм</param> /// <returns></returns> [DllImport("user32.dll")] public static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent); 

The following example in the form class body binds a window of a third-party process, to panel1. You can bind directly to the form, but in my practice it turned out to be more convenient. Pay attention to the expectations - they may be needed, may not "depends on ..."

 var proc = System.Diagnostics.Process.Start(exepath); //Π—Π΄Π΅ΡΡŒ ΠΌΠΎΠΆΠ΅Ρ‚ ΠΏΠΎΠ½Π°Π΄ΠΎΠ±ΠΈΡ‚ΡŒΡΡ ΠΎΠΆΠΈΠ΄Π°Π½ΠΈΠ΅ // Thread.Sleep(1000); if (proc.WaitForInputIdle(TimeSpan.FromSeconds(30).TotalMilliseconds)) { //Π—Π΄Π΅ΡΡŒ Ρ‚ΠΎΠΆΠ΅ ΠΌΠΎΠΆΠ΅Ρ‚ ΠΏΠΎΠ½Π°Π΄ΠΎΠ±ΠΈΡ‚ΡŒΡΡ ΠΎΠΆΠΈΠ΄Π°Π½ΠΈΠ΅ //Thread.Sleep(2000); SetParent(proc.MainWindowHandle, this.panel1.Handle); } 
     Process.Start("C:\\WinAsm\\WinAsm.exe"); 

    or

     Process.Start(@"C:\WinAsm\WinAsm.exe");