In the program execution will encounter the launch of the software EXE asked, or enable other EXE files, has achieved the role of some operations performed. Here are two of the most common startup exe files.
1. Call the system DLL using the method it provides.
The referenced DLL,
[CSharp]View Plaincopyprint?
- [DllImport ("kernel32.dll")]
- public static extern int winexec (string exename, int opertype);
Called, winexec (@ "path \exe filename", parameter);
The opertype parameters are as follows:
[CSharp]View Plaincopyprint?
- 0: Hidden, and the taskbar does not have a minimized icon
- 1: Display with the nearest size and position, activate
- 2: Minimize, activate
- 3: Maximize, activate
- 4: Display with the nearest size and position, do not activate
- 5: Same 1
- 6: Minimize, do not activate
- 7: Same 3
- 8: Same 3
- 9: Same 1
- 10: Same 1
2, the most common ProcessStartInfo start-up
[CSharp]View Plaincopyprint?
- ProcessStartInfo info = new ProcessStartInfo ();
- Info. filename = @"path \exe file name";
- Info. Arguments = "";
- Info. WindowStyle = processwindowstyle.minimized;
- Process Pro = Process.Start (info);
- Pro. WaitForExit ();
3. End the process of starting EXE
[CSharp]View Plaincopyprint?
- process[] Allprogresse = System.Diagnostics.Process.GetProcessesByName ("EXE's process name");
- foreach (Process closeprogress in allprogresse)
- {
- if (closeProgress.ProcessName.Equals ("EXE's process name"))
- {
- Closeprogress.kill ();
- Closeprogress.waitforexit ();
- Break ;
- }
- }
C # Start and end a thread