0
你好我想重新使用一些代码,我指着前面运行第三方.exe
一个我的winform里面的WinForms - 类范围
我得到的代码通过先生
Greg Young的
public class Native {
[DllImport("user32.dll", SetLastError = true)]
private static extern uint SetParent(IntPtr hWndChild, IntPtr hWndNewParent);
public static void LoadProcessInControl(string _Process, Control _Control)
{
System.Diagnostics.Process p = System.Diagnostics.Process.Start(_Process);
p.WaitForInputIdle();
Native.SetParent(p.MainWindowHandle, _Control.Handle);
}
}
地方执行会
public partial class Form1 : Form {
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
LoadProcessInControl("notepad.exe", this.splitContainer1.Panel1);
LoadProcessInControl("notepad.exe", this.splitContainer1.Panel2);
}
}
但是我一直GETT ing错误:
The name 'LoadProcessInControl' does not exist in the current context
类的范围仍然是我的编程知识中的一个弱点,我希望能更好地理解它。
我已经试过类切换到公众和方法(负载procincontrol)去除静态的,但我没有得到任何地方)
感谢您的帮助
说让我“是必需的非静态字段,方法或属性‘Perls.Form1.Native.LoadProcessInControl(字符串,System.Windows.Forms.Control的)’的对象引用\t ” – Crash893 2009-12-03 19:12:36
没关系它的工作原理(我删除了静态OC,忘了把它放回)谢谢 – Crash893 2009-12-03 19:14:07