samedi 28 mars 2015

c# open an windows form app another

there I try to open an wfapp from another and when I run the code :An unhandled exception of type 'System.ComponentModel.Win32Exception' occurred in System.dll There is the code:



private void button2_Click(object sender, EventArgs e)
{

Panel panel1 = new Panel();


Process p = Process.Start("ap.exe");
//Thread.Sleep(500); // Allow the process to open it's window
SetParent(p.MainWindowHandle, panel1.Handle);
}

[DllImport("user32.dll")]
static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);

Aucun commentaire:

Enregistrer un commentaire