to run an exe file in the panel of c#.net application

女生的网名这么多〃 提交于 2019-11-28 06:31:16

问题


  1. I want to run an exe file on my winform .net application within the panel using c# code
  2. I'm able to run exe file on the button click with System.Diagnostics.ProcessStartInfo and Process p = Process.Start("notepad.exe"); but what is the code to run this notepad file or any other exe file within the panel using c# code?
  3. I want to run the application within the panel not on the separate window.i had run the following code but the exe does not stay on the screen nor it opens within the panel please tell me the solution for this.

        Process p = Process.Start("notepad.exe");
        Thread.Sleep (600);  // Allow the process to open it's window 
        SetParent(p.MainWindowHandle, panel1.Handle);
    
    
    [DllImport("user32.dll")]
    static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);
    

回答1:


I think what you are talking about is embedding an application in your panel.

This is only possibly with executables that have been created to be embedded. Notepad is not one of those. Some browsers can be - Mozilla is one example, and IE is another.




回答2:


I guess you are looking for this: Window Tabifier




回答3:


What are you trying to do? you know that if its your own programs you want to run in the panel you could write some basic plugin code and get a control from a assembly with reflection..




回答4:


What you want is pipe the output of the exe to your process. Usually when you do not do not pipe the output it defaults to stdout for a console application will be the console window by piping you are telling the exe you want the output to come to your process not the console window. Then you would have to create your own "panel" (a multiline textbox) and append the the output stream from the exe you invoked to it!

Learn here: http://msdn.microsoft.com/en-us/library/system.diagnostics.processstartinfo.redirectstandardoutput(v=VS.90).aspx



来源:https://stackoverflow.com/questions/2160767/to-run-an-exe-file-in-the-panel-of-c-net-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!