C # embed an external exe program into your own form interface,
Put the exe program developed by others into your own form to run.
1. Basic functions
First, add the code behind your own form:
[DllImport("User32.dll", EntryPoint = "SetParent")] private static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent); [DllImport("user32.dll", EntryPoint = "ShowWindow")] private static extern int ShowWindow(IntPtr hwnd, int nCmdShow);
Add the code as needed:
String fexePath = @ "XXX \ Files \ Debug \ VsTest.exe"; // external exe position Process p = new Process (); p. startInfo. fileName = fexePath; p. startInfo. windowStyle = ProcessWindowStyle. normal; p. start (); while (p. main1_whandle. toInt32 () = 0) {System. threading. thread. sleep (100);} SetParent (p. main1_whandle, this. handle); ShowWindow (p. mainWindowHandle, (int) ProcessWindowStyle. maximized );
You can:
[Http://www.cnblogs.com/cuit-dx037 /]