C # Start the EXE file (simple)

Source: Internet
Author: User

When executing a program, you may encounter an EXE question about starting the software, or enable other EXE files, which has been used to execute some operations. The following are the two most common startup EXE files.

1. Call the system DLL to use the provided method.

Referenced DLL,

 [DllImport("kernel32.dll")]   public static extern int WinExec(string exeName, int operType);

Call, winexec (@ "path \ exe file name", parameter );

Opertype parameters are as follows:

0: Hide, And the taskbar does not minimize the icon 1: Display with the nearest size and position, activate 2: Minimize, activate 3: Maximize, activate 4: display with the latest size and position. Do not activate 5: The same as 16: The minimum, do not activate 7: The same as 38: The same as 39: The same 110: The same 1

2. The most common processstartinfo startup

Processstartinfo info = new processstartinfo (); info. filename = @ "path \ exe file name"; info. arguments = ""; info. windowstyle = processwindowstyle. minimized; process pro = process. start (Info); pro. waitforexit ();

3. Stop the started EXE process

Process [] allprogresse = system. diagnostics. process. getprocessesbyname ("EXE process name"); foreach (process closeprogress in allprogresse) {If (closeprogress. processname. equals ("EXE process name") {closeprogress. kill (); closeprogress. waitforexit (); break ;}}

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.