1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
| public partial class MainForm : Form
{
public MainForm()
{
//
// The InitializeComponent() call is required for Windows Forms designer support.
//
InitializeComponent();
}
//
// TODO: Add constructor code after the InitializeComponent() call.
//
[DllImport("user32.dll")]
static extern IntPtr SetParent (IntPtr hwc ,IntPtr hwp);
void Button1Click(object sender, EventArgs e)
{
//Process process = new Process();
//process.StartInfo.CreateNoWindow=true;
//process.StartInfo.UseShellExecute = false;
//process.StartInfo.FileName = "notepad.exe";
//process.Start();
//OK
Process p;
p = new Process();
p = Process.Start("calc.exe");
//p = Process.Start(@"notepad.exe");
//p = Process.Start(@"C:\\Program Files\\MSCom2\\mdiapp.exe");
//p = Process.Start(@"C:\\Program Files\\SoftReal\\EuroCAP\\EuroCAP.exe");
Thread.Sleep(500);
p.WaitForInputIdle();
SetParent(p.MainWindowHandle,this.Handle);
//FIN OK
} |
Partager