view plain copy to clipboard print ?
1. [DllImport("User32.dll",EntryPoint="SetParent")]
2.
3. privatestaticexternIntPtrSetParent(IntPtrhWndChild,IntPtrhWndNe
wParent);
4.
5. [DllImport("user32.dll",EntryPoint="ShowWindow")]
6.
7. publicstaticexternintShowWindow(IntPtrhwnd,intnCmdShow);
8.
9. privatevoidbutton3_Click(objectsender,EventArgse)
10.
11. {
12.
13. Processp=newProcess();
14.
15. p.StartInfo.FileName="cmd.exe";
16.
17. p.StartInfo.WindowStyle=System.Diagnostics.ProcessWindow
Style.Minimized;//加上这句效果更好
18.
19. p.Start();
20.
21. System.Threading.Thread.Sleep(100);//加上,100 如果效果没有就
继续加大
22.
23.
24.
25. SetParent(p.MainWindowHandle,panel1.Handle);//
panel1.Handle 为要显示外部程序的容器
26.
27. ShowWindow(p.MainWindowHandle,3);
28.
29. }
- 1
- 2
- 3
前往页