C# 是否可以在表单的面板中打开应用程序,如Google chrome
我不知道这是否可能 我可以在外面单独打开它C# 是否可以在表单的面板中打开应用程序,如Google chrome,c#,panel,C#,Panel,我不知道这是否可能 我可以在外面单独打开它 System.Diagnostics.Process.Start("FileName"); 我也试过了 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Window
System.Diagnostics.Process.Start("FileName");
我也试过了
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Threading;
namespace wmpkhela
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Process p = Process.Start(@"notepad.exe");
p.WaitForInputIdle();
SetParent(p.MainWindowHandle, panel1..Handle);
}![enter image description here][1]
[DllImport("user32.dll")]
static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);
private void Form1_Load(object sender, EventArgs e)
{
}
}
}
但这并没有像我预期的那样工作我想您正在寻找,而且可能是重复的。请参见使用这两个函数在面板中放置任何其他进程
[DllImport("user32.dll", SetLastError = true)]
private static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);
[DllImport("user32.dll", EntryPoint = "SetWindowPos")]
public static extern IntPtr SetWindowPos(IntPtr hWnd, int hWndInsertAfter, int x, int Y, int cx, int cy, int wFlags);
进程p=Process.Startnotepad.exe;线程。睡眠600;//允许进程打开其窗口SetParentp.MainWindowHandle,panel1.Handle;[DllImportuser32.dll]静态外部IntPtr SetParentIntPtr hWndChild,IntPtr hWndNewParent;这不起作用: