在c#.net应用程序的面板中运行exe文件
- 我想使用 c# 代码在面板内的 winform .net 应用程序上运行 exe 文件
- 我可以使用
System.Diagnostics.ProcessStartInfo
和Process p 在按钮单击上运行 exe 文件= Process.Start("notepad.exe");
但是使用 C# 代码运行此记事本文件或面板内任何其他 exe 文件的代码是什么? 我想在面板内运行应用程序,而不是在单独的窗口上运行。我已运行以下代码,但 exe 不会停留在屏幕上,也不会在面板内打开 请告诉我解决方案。
Process p = Process.Start("notepad.exe"); 线程.睡眠 (600); // 允许进程打开它的窗口 SetParent(p.MainWindowHandle, panel1.Handle); [DllImport("user32.dll")] 静态 extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);
- I want to run an exe file on my winform .net application within the panel using c# code
- I'm able to run exe file on the button click with
System.Diagnostics.ProcessStartInfo
andProcess 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? 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);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我认为您所说的是在面板中嵌入应用程序。
这仅适用于已创建的要嵌入的可执行文件。记事本不是其中之一。某些浏览器可以是 - Mozilla 就是一个例子,IE 是另一个。
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.
我猜您正在寻找这个: Window Tabifier
I guess you are looking for this: Window Tabifier
你想做什么?您知道,如果您想在面板中运行您自己的程序,您可以编写一些基本的插件代码并通过反射从程序集中获取控件。
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..
您想要的是将 exe 的输出通过管道传输到您的进程。通常,当您不通过管道传输输出时,控制台应用程序的默认标准输出将是控制台窗口,通过管道您告诉 exe 您希望输出到达您的进程而不是控制台窗口。然后,您必须创建自己的“面板”(多行文本框)并将您调用的 exe 的输出流附加到它!
在此了解:http:// /msdn.microsoft.com/en-us/library/system.diagnostics.processstartinfo.redirectstandardoutput(v=VS.90).aspx
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