System. Diagnostics. Process. Start (); what can be done? It provides the following functions:
1. Open a URL (pop-up window ).
2. Locate and open a file directory.
3. Open special system folders, such as "Control Panel.
So how does it implement these functions? Before talking about the application, let's take a look at the construction method of Process. Star.
| Name |
Description |
| Process. Start () |
Start (or reuse) The Process resource specified by the StartInfo attribute of this Process component and associate it with this component. |
| Process. Start (ProcessStartInfo) |
Start the Process resource specified by the parameter that contains the Process startup information (for example, the name of the Process to be started) and associate the resource with the new Process component. |
| Process. Start (String) |
You can specify the name of a document or application file to start the Process resource and associate the resource with the new Process component. |
| Process. Start (String, String) |
You can specify an application name and a set of command line parameters to start a Process resource and associate the resource with the new Process component. |
| Process. Start (String, String, SecureString, String) |
Start a Process resource by specifying the application name, user name, password, and domain, and associate the resource with the new Process component. |
| Process. Start (String, SecureString, String) |
You can specify an application name and a group of command line parameters, user names, passwords, and domains to start a Process resource and associate the resource with the new Process component. |
(1) publicbool Start ()
System. Diagnostics. Process process = new System. Diagnostics. Process ();
Process. StartInfo. FileName = "iexplore.exe"; // IE browser, which can be changed
Process. StartInfo. Arguments = "http://www.baidu.com ";
Process. Start ();
(2) publicstaticProcessStart
(ProcessStartInfostartInfo)
System. Diagnostics. ProcessStartInfo processStartInfo = new System. Diagnostics. ProcessStartInfo ();
ProcessStartInfo. FileName = "assumer.exe"; // Resource Manager
ProcessStartInfo. Arguments = @ "D :\";
System. Diagnostics. Process. Start (processStartInfo );
(3) publicstaticProcessStart
(StringfileName)
System. Diagnostics. Process. Start (@ "D: \ Program Files \ Tencent \ QQ \ Bin \ QQ.exe"); // directly call to open the file
(4) Process. Start (StringfileName,
Stringarguments)
System. Diagnostics. Process. Start ("assumer.exe", "D: \ Readme.txt"); // open the Readme.txt file directly.
The preceding example shows how to use process. start () to open a website. Now let's talk about how to use processs. star () to locate a file.
This method is similar to the search target in the shortcut: // explorer/select, "D: \ Program Files \ Tencent \ QQ \ Bin \ QQ.exe"
String path = @ "D: \ Program Files \ Tencent \ QQ \ Bin \ QQ.exe ";
System. Diagnostics. Process. Start ("assumer.exe", "/select," + path); // open the D: \ Program Files \ Tencent \ QQ \ binfile directory and select qq.exe
Note: There is a comma (,) after/select (,).
The following is a simple introduction to the functions and functions of rundll32.exe.
As the name implies, rundll32 is the "32-bit dll file execution", that is, the internal function in the dll file execution. It can call the dynamic link library of Windows 32-bit in the form of a command line.
Likewise, rundll.exe is "executing 16-bit dll files" and calls a 16-bit dynamic link library. We use rundll32.exe to execute commands to complete some functions.
For example:
System. Diagnostics. Process. Start ("rundll32.exe", "user.exe, restartwindows"); // System restart command
Rundll32 command Overview
Command column: rundll32.exe user.exe, restartwindows
Function: restarts the system.
Command column: rundll32.exe user.exe, exitwindows
Function: disable the system.
Command column: rundll32.exe shell32.dll, Control_RunDLL
Function: Display Control Panel
Command column: rundll32.exe shell32.dll, Control_RunDLL access. cpl, 1
Function: displays the "control panel-Auxiliary options-keyboard" option window.
Command column: rundll32.exe shell32.dll, Control_RunDLL access. cpl, 2
Function: displays the "control panel-Auxiliary options-sound" option window.
Command column: rundll32.exe shell32.dll, Control_RunDLL access. cpl, 3
Function: displays the "control panel-Auxiliary options-display" option window.
Command column: rundll32.exe shell32.dll, Control_RunDLL access. cpl, 4
Function: displays the control panel-secondary option-mouse option window.
Command column: rundll32.exe shell32.dll, Control_RunDLL access. cpl, 5
Function: displays the "control panel-Auxiliary options-traditional" option window.
Command column: rundll32.exe shell32.dll, Control_RunDLL sysdm. cpl @ 1
Function: run the "control panel-add new hardware" Wizard.
Command column: rundll32.exe shell32.dll, SHHelpShortcuts_RunDLL AddPrinter
Function: run the control panel-add new printer wizard.
Command column: rundll32.exe shell32.dll, Control_RunDLL appwiz. cpl, 1
Function: displays the "control panel-Add/delete programs" panel.
Command column: rundll32.exe shell32.dll, Control_RunDLL appwiz. cpl, 1
Function: the "control panel-Add/delete programs-install/uninstall" panel is displayed.
Command column: rundll32.exe shell32.dll, Control_RunDLL appwiz. cpl, 2
Function: the "control panel-Add/delete programs-install Windows" panel is displayed.
Command column: rundll32.exe shell32.dll, Control_RunDLL appwiz. cpl, 3
Function: the "control panel-Add/delete programs-boot disk" panel is displayed.
Command column: rundll32.exe syncui. dll, Briefcase_Create
Function: Create a new "My Briefcase" on the desktop ".
Command column: rundll32.exe diskcopy. dll, DiskCopyRunDll
Function: displays the copy disk Window.
Command column: rundll32.exe apwiz. cpl, NewLinkHere % 1
Function: the "Create shortcut" dialog box is displayed. The location of the created shortcut is determined by the % 1 parameter.
Command column: rundll32.exe shell32.dll, Control_RunDLL timedate. cpl, 0
Function: displays the "Date and Time" option window.
Command column: rundll32.exe shell32.dll, Control_RunDLL timedate. cpl, 1
Function: displays the "Time Zone" option window.
Command column: rundll32.exe rnaui. dll, RnaDial [name of a dial-up connection]
Function: displays the dialing window for a dial-up connection. If a dial-up connection has been established, the current connection status window is displayed.
Command column: rundll32.exe rnaui. dll, RnaWizard
Function: displays the window of the new dial-up connection wizard.
Command column: rundll32.exe shell32.dll, Control_RunDLL desk. cpl, 0
Function: displays the "Display Properties-background" option window.
Command column: rundll32.exe shell32.dll, Control_RunDLL desk. cpl, 1
Function: displays the "Display Properties-Screen Saver" option window.
Command column: rundll32.exe shell32.dll, Control_RunDLL desk. cpl, 2
Function: displays the display properties-appearance option window.
Command column: rundll32.exe shell32.dll, Control_RunDLL desk. cpl, 3
Function: displays the "show properties-properties" option window.
Command column: rundll32.exe shell32.dll, SHHelpShortcuts_RunDLL FontsFolder
Function: display the "font" folder of Windows.
Command column: rundll32.exe shell32.dll, Control_RunDLL main. cpl @ 3
Function: displays the "font" folder of Windows.
Command column: rundll32.exe shell32.dll, SHFormatDrive
Function: displays the formatting dialog box.
Command column: rundll32.exe shell32.dll, Control_RunDLL joy. cpl, 0
Function: displays the "control panel-Game Controller-General" option window.
Command column: rundll32.exe shell32.dll, Control_RunDLL joy. cpl, 1
Function: displays the "control panel-game controller-advanced" option window.
Command column: rundll32.exe mshtml. dll, PrintHTML (HTML document)
Function: Print HTML documents.
Command column: rundll32.exe shell32.dll, Control_RunDLL ml1_32.cpl
Function: displays the Microsoft Exchange General options window.
Command column: rundll32.exe shell32.dll, Control_RunDLL main. cpl @ 0
Function: displays the "control panel-mouse" option.
Command column: rundll32.exe shell32.dll, Control_RunDLL main. cpl @ 1
Function: displays the "control panel-keyboard properties-speed" option window.
Command column: rundll32.exe shell32.dll, Control_RunDLL main. cpl @ 1, 1
Function: displays the "control panel-keyboard properties-language" option window.
Command column: rundll32.exe shell32.dll, Control_RunDLL main. cpl @ 2
Function: displays the Windows "Printer" folder.
Command column: rundll32.exe shell32.dll, Control_RunDLL main. cpl @ 4
Function: displays the "control panel-Input Method properties-Input Method" option window.
Command column: rundll32.exe shell32.dll, Control_RunDLL modem. cpl, add
Function: run the Add new modem wizard.
Command column: rundll32.exe shell32.dll, Control_RunDLL mmsys. cpl, 0
Function: displays the "control panel-multimedia properties-Audio" property page.
Command column: rundll32.exe shell32.dll, Control_RunDLL mmsys. cpl, 1
Function: displays the "control panel-multimedia properties-video" property page.
Command column: rundll32.exe shell32.dll, Control_RunDLL mmsys. cpl, 2
Function: displays the "control panel-multimedia properties-MIDI" property page.
Command column: rundll32.exe shell32.dll, Control_RunDLL mmsys. cpl, 3
Function: displays the "control panel-multimedia properties-CD music" property page.
Command column: rundll32.exe shell32.dll, Control_RunDLL mmsys. cpl, 4
Function: displays the "control panel-multimedia properties-devices" property page.
Command column: rundll32.exe shell32.dll, Control_RunDLL mmsys. cpl @ 1
Function: displays the control panel-sound option window.
Command column: rundll32.exe shell32.dll, Control_RunDLL netcpl. cpl
Function: displays the control panel-Network option window.
Command column: rundll32.exe shell32.dll, Control_RunDLL odbccp32.cpl
Function: displays the ODBC32 data management option window.
Command column: rundll32.exe shell32.dll, OpenAs_RunDLL {drive:/path/filename}
Function: displays the open mode dialog box for the specified file (drive:/path/filename.
Command column: rundll32.exe shell32.dll, Control_RunDLL password. cpl
Function: the "control panel-Password" option window is displayed.
Command column: rundll32.exe shell32.dll, Control_RunDLL powercfg. cpl
Function: displays the "control panel-Power Management Properties" option window.
Command column: rundll32.exe shell32.dll, SHHelpShortcuts_RunDLL PrintersFolder
Function: displays the Windows "Printer" folder. (Same as rundll32.exe shell32.dll, Control_RunDLL main. cpl @ 2)
Command column: rundll32.exe shell32.dll, Control_RunDLL intl. cpl, 0
Function: the "control panel-region settings properties-region Settings" option window is displayed.
Command column: rundll32.exe shell32.dll, Control_RunDLL intl. cpl, 1
Function: displays the "control panel-region settings properties-numbers" option window.
Command column: rundll32.exe shell32.dll, Control_RunDLL intl. cpl, 2
Function: the "control panel-region settings properties-currency" option window is displayed.
Command column: rundll32.exe shell32.dll, Control_RunDLL intl. cpl, 3
Function: displays the "control panel-region settings property-time" option window.
Command column: rundll32.exe shell32.dll, Control_RunDLL intl. cpl, 4
Function: displays the "control panel-region settings properties-Date" option window.
Command column: rundll32.exe desk. cpl, InstallScreenSaver [Screen saver file name]
Function: sets the specified screen saver file to Windows and displays the screen saver Properties window.
Command column: rundll32.exe shell32.dll, Control_RunDLL sysdm. cpl, 0
Function: displays the "control panel-system properties-traditional" attribute window.
Command column: rundll32.exe shell32.dll, Control_RunDLL sysdm. cpl, 1
Function: displays the "control panel-system properties-Device Manager" Properties window.
Command column: rundll32.exe shell32.dll, Control_RunDLL sysdm. cpl, 2
Function: displays the "control panel-system properties-hardware configuration file" attribute window.
Command column: rundll32.exe shell32.dll, Control_RunDLL sysdm. cpl, 3
Function: displays the "control panel-system properties-performance" attribute window.
Command column: rundll32.exe shell32.dll, Control_RunDLL telephon. cpl
Function: displays the "dial property" option window.
Command column: rundll32.exe shell32.dll, Control_RunDLL themes. cpl
Function: displays the desktop topic option panel.
Command column: rundll32.exe shell32.dll, Control_RunDLL firewall. cpl
Function: displays the Windows Firewall panel.
Command column: rundll32.exe shell32.dll, Control_RunDLL NetSetup. cpl, @ 0, WNSW
Function: displays the "wireless network settings" panel.
For more commands Please download here: http://download.csdn.net/detail/czw2010/4530206
System. Diagnostics. Process. Start ("notepad.exe"); -- open notepad
System. Diagnostics. Process. Start ("calc.exe"); -- open the calculator.
System. Diagnostics. Process. Start ("regedit.exe"); -- open the Registry
System. Diagnostics. Process. Start ("mspaint.exe"); -- open the palette
System. Diagnostics. Process. Start ("write.exe"); -- open the WordPad
System. Diagnostics. Process. Start ("mplayer2.exe"); -- enable the player.
System. Diagnostics. Process. Start ("taskmgr.exe"); -- open the task manager.
System. Diagnostics. Process. Start ("eventvwr.exe"); -- open the event viewer.
System. Diagnostics. Process. Start ("winmsd.exe"); -- open the System information
System. Diagnostics. Process. Start ("winver.exe"); -- enable Windows version information.
System. Diagnostics. Process. Start ("mailto:" + address); -- send an email
Shutdown.exe:
Parameter:-s shutdown-r restart-f forced-t time-a cancel shutdown-l logout-I display the user interface
System. Diagnostics. Process. Start ("shutdown.exe", "-r"); -- shut down and restart the computer
System. Diagnostics. Process. Start ("shutdown.exe", "-s-f"); -- disable the computer
System. Diagnostics. Process. Start ("shutdown.exe", "-s-f 30"); -- close the computer after 30 s
System. Diagnostics. Process. Start ("shutdown.exe", "-l ");
-- Log out of the computer
System. Diagnostics. Process. Start ("shutdown.exe", "-a"); -- undo
SpecialFolder enumeration members:
| Member name |
Description |
| ApplicationData |
Directory, which is used as a public repository for the application-specific data of the Current roaming user. Roaming users work on multiple computers on the network. The configuration file of the roaming user is saved on the network server. When the user logs on to a system, it is loaded to the system. |
| CommonApplicationData |
Directory, which is a public repository of application-specific data used by all users. |
| CommonProgramFiles |
Directory of components shared between applications. |
| Cookies |
The Directory of the public repository used as the Internet Cookie. |
| Desktop |
Logical desktop, rather than physical file system location. |
| DesktopDirectory |
The directory used to physically store the file objects on the desktop. This directory should not be confused with the Desktop Folder, which is a virtual folder. |
| Favorites |
The directory used as the public repository for user favorites items. |
| History |
The directory used as the public repository for Internet history items. |
| InternetCache |
Directory used as the public repository for Internet temporary files. |
| LocalApplicationData |
Directory, which is used as a public repository for application-specific data used by non-roaming users. |
| MyComputer |
"My Computer" folder.
| Note: |
Because no path is defined for the "my computer" folder, The MyComputer constant will always generate an empty string (""). |
|
| MyDocuments |
"My Computer" folder. |
| MyMusic |
"My Music" folder. |
| MyPictures |
"My Pictures" folder. |
| Personal |
Directory used as the public repository of the document. |
| ProgramFiles |
"Program files" directory. |
| Programs |
Directory that contains the user program group. |
| Recent |
The directory that contains the documents recently used by the user. |
| SendTo |
The directory that contains the "send" menu item. |
| StartMenu |
The directory that contains the "Start" menu item. |
| Startup |
The directory corresponding to the user's "start" program group. The system starts these programs whenever you log on to, start Windows NT or later, or start Windows 98. |
| System |
"System" directory. |
| Templates |
Directory of the public repository used as the document template. |
Through Environment. GetFolderPath (Environment. SpecialFolder. XXXXX); we can easily obtain the specific path of the system's special folder, and then open the folder using the Process. Start () method.
For example:
System. Diagnostics. Process. Start (Environment. GetFolderPath (Environment. SpecialFolder. System); // open the System folder (System32 folder)
[System. Runtime. InteropServices. DllImportAttribute ("user32.dll")]
Private static extern int FindWindow (string ClassName, string WindowName );
[System. Runtime. InteropServices. DllImport ("user32.dll")]
Private static extern int ShowWindow (int handle, int cmdShow );
[System. Runtime. InteropServices. DllImport ("winmm. dll", EntryPoint =
"MciSendString", CharSet = System. Runtime. InteropServices. CharSet. Auto)]
Private static extern int mciSendString (string lpstrCommand,
String lpstrReturnstring, int uReturnLength, int hwndCallback );
Private const int SW_HIDE = 0; // The API parameter indicates hiding the window.
Private const int SW_SHOW = 5; // The API parameter indicates that the window is displayed with the current size and position
ShowWindow (FindWindow ("Shell_TrayWnd", null), SW_HIDE); -- hide the taskbar
ShowWindow (FindWindow ("Shell_TrayWnd", null), SW_SHOW); -- display the taskbar
MciSendString ("set CDAudio door open", null, 127, 0); -- the optical drive is displayed.
MciSendString ("set CDAudio door closed", null, 127, 0); -- disable the optical drive