This article describes the C# operation class that calls DOS commands. Share it for your reference. The details are as follows:
/****************************************************** * All Rights Reserved , Copyright (C) 2012 , EricHu. * Author: EricHu * Created: 2012-5-4 15:29:35 *********************************************/ using System; using ; using ; namespace { /// <summary> /// /// DosHelper /// Dos commonly used operation classes /// /// </summary> public class DosHelper { //Introduce API functions [DllImportAttribute("")] private static extern int FindWindow(string ClassName, string WindowName); [DllImport("")] private static extern int ShowWindow(int handle, int cmdShow); [DllImport("", EntryPoint = "mciSendString", CharSet = )] private static extern int mciSendString(string lpstrCommand,string lpstrReturnstring,int uReturnLength,int hwndCallback); private const int SW_HIDE = 0;//API parameters indicate hidden window private const int SW_SHOW = 5;//API parameters indicate the display window with the current size and position public void Pop-up optical drive() { mciSendString("set CDAudio door open", null, 127, 0); } public void Turn off the optical drive() { mciSendString("set CDAudio door closed", null, 127, 0); } public void OpenCplate() { ("c:\"); } public void OpenDplate() { ("d:\"); } public void OpenEplate() { ("e:\"); } public void OpenFplate() { ("f:\"); } public void Open指定plate(string hardpath) { (hardpath); } public void OpenWord() { (@"C:Program FilesMicrosoft "); } public void OpenExcel() { (@"C:Program FilesMicrosoft "); } public void OpenAccess() { (@"C:Program FilesMicrosoft "); } public void OpenPowerPoint() { (@"C:Program FilesMicrosoft "); } public void OpenOutLook() { (@"C:Program FilesMicrosoft "); } public void Open记事本() { (""); } public void Open计算器() { (""); } public void OpenDOSCommand Window() { (""); } public void Open注册表() { (""); } public void Open画图板() { (""); } public void Open写字板() { (""); } public void Open播放器() { (""); } public void Open资源管理器() { (""); } public void Open任务管理器() { (""); } public void Open事件查看器() { (""); } public void Open系统信息() { (""); } public void Open备份还原() { (""); } public void OpenWindowsVersion() { (""); } public void Open控制panel() { ("", ",Control_RunDLL"); } public void Open控制panel辅助选项键plate() { ("", ",Control_RunDLL ,,1"); } public void Open控制panel辅助选项声音() { ("", ",Control_RunDLL ,,2"); } public void Open控制panel辅助选项显示() { ("", ",Control_RunDLL ,,3"); } public void Open控制panel辅助选项鼠标() { ("", ",Control_RunDLL ,,4"); } public void Open控制panel辅助选项常规() { ("", ",Control_RunDLL ,,5"); } public void Open控制panel添加新硬件向导() { ("", ",Control_RunDLL @1"); } public void Open控制panel添加新打印机向导() { ("", ",SHHelpShortcuts_RunDLL AddPrinter"); } public void Open控制panel添加删除程序安装卸载panel() { ("", ",,Control_RunDLL ,,1"); } public void Open控制panel添加删除程序安装Windowspanel() { ("", ",,Control_RunDLL ,,2"); } public void Open控制panel添加删除程序启动platepanel() { ("", ",,Control_RunDLL ,,3"); } public void Open建立快捷方式对话框() { ("", " ,NewLinkHere %1"); } public void Open日期时间选项() { ("", " ,Control_RunDLL ,,0"); } public void Open时区选项() { ("", " ,Control_RunDLL ,,1"); } public void Create a briefcase() { ("", " ,Briefcase_Create"); } public void Open复制软碟窗口() { ("", " ,DiskCopyRunDll"); } public void Open新建拨号连接() { ("", " ,RnaWizard"); } public void Open显示属性背景() { ("", " ,Control_RunDLL ,,0"); } public void Open显示属性屏幕保护() { ("", " ,Control_RunDLL ,,1"); } public void Open显示属性外观() { ("", " ,Control_RunDLL ,,2"); } public void Open显示属性属性() { ("", " ,Control_RunDLL ,,3"); } public void Open格式化对话框() { ("", " ,SHFormatDrive"); } public void Open控制panel游戏控制器一般() { ("", " ,Control_RunDLL ,,0"); } public void Open控制panel游戏控制器进阶() { ("", " ,Control_RunDLL ,,1"); } public void Open控制panel键plate属性速度() { ("", " ,Control_RunDLL @1"); } public void Open控制panel键plate属性语言() { ("", " ,Control_RunDLL @1,,1"); } public void OpenWindowsPrinter file folder() { ("", " ,Control_RunDLL @2"); } public void OpenWindowsFont file folder() { ("", " ,Control_RunDLL @3"); } public void Open控制panel输入法属性() { ("", " ,Control_RunDLL @4"); } public void Open添加新调制解调器向导() { ("", " ,Control_RunDLL ,,add"); } public void Open控制panel多媒体属性音频() { ("", " ,Control_RunDLL ,,0"); } public void Open控制panel多媒体属性视频() { ("", " ,Control_RunDLL ,,1"); } public void Open控制panel多媒体属性MIDI() { ("", " ,Control_RunDLL ,,2"); } public void Open控制panel多媒体属性CDmusic() { ("", " ,Control_RunDLL ,,3"); } public void Open控制panel多媒体属性设备() { ("", " ,Control_RunDLL ,,4"); } public void Open控制panel声音() { ("", " ,Control_RunDLL @1"); } public void Open控制panel网络() { ("", " ,Control_RunDLL "); } public void Open控制panel密码() { ("", " ,Control_RunDLL "); } public void Open控制panel电源管理() { ("", " ,Control_RunDLL "); } public void Open控制panel区域设置属性区域设置() { ("", " ,Control_RunDLL ,,0"); } public void Open控制panel区域设置属性数字选项() { ("", " ,Control_RunDLL ,,1"); } public void Open控制panel区域设置属性货币选项() { ("", " ,Control_RunDLL ,,2"); } public void Open控制panel区域设置属性时间选项() { ("", " ,Control_RunDLL ,,3"); } public void Open控制panel区域设置属性日期选项() { ("", " ,Control_RunDLL ,,4"); } public void OpenODBCData Source Manager() { ("", " ,Control_RunDLL "); } public void Open控制panel系统属性常规() { ("", " ,Control_RunDLL ,,0"); } public void Open控制panel系统属性设备管理器() { ("", " ,Control_RunDLL ,,1"); } public void Open控制panel系统属性硬件配置() { ("", " ,Control_RunDLL ,,2"); } public void Open控制panel系统属性性能() { ("", " ,Control_RunDLL ,,3"); } /*shutdown -s -t 3600 -f Forced shutdown after one hour. I am afraid that some programs can be stuck and cannot shut down the machine. -s Shutdown -rRestart -f Forced -t Time -a Cancel shutdown -l Logout -i Display the user interface. Try it and you will know what it is. public void Turn off and restart the computer() { ("", "-r"); } public void Turn off the computer() { ("", "-s -f"); } //Reload the computer function and set the countdown public void Turn off the computer(string time) { string s = "-s -t " + time; ("", s); } public void Log out of the computer() { ("", "-l"); } public void 撤销Turn off the computer() { ("", "-a"); } public void Open桌面主旨panel() { ("", " ,Control_RunDLL "); } public void Open网址(string address) { (address); } public void Run the program(string name) { (name); } public void Show taskbar() { ShowWindow(FindWindow("Shell_TrayWnd", null), SW_SHOW); } public void Hide taskbar() { ShowWindow(FindWindow("Shell_TrayWnd", null), SW_HIDE); } public void Send an email(string address) { string s = "mailto:" + address; (s); } public void Send an email() { ("mailto:80368704@"); } public string Get the system folder() { string s = (); return s; } public void Open系统Folders() { string s = (); (s); } public string GetProgramFilesTable of contents() { string s = (); return s; } public void OpenProgramFilesTable of contents() { string s = (); (s); } public string Get逻辑桌面() { string s = (); return s; } public void Open逻辑桌面() { string s = (); (s); } public string Get启动程序组() { string s = (); return s; } public void Open启动程序组() { string s = (); (s); } public string GetCookiesFolders() { string s = (); return s; } public void OpenCookiesFolders() { string s = (); (s); } public string GetInternet历史Folders() { string s = (); return s; } public void OpenInternet历史Folders() { string s = (); (s); } public string Get我的电脑Folders() { string s = (); return s; } public void Open我的电脑Folders() { string s = (); (s); } public string GetMyMusicFolders() { string s = (); return s; } public void OpenMyMusicFolders() { string s = (); (s); } public string GetMyPicturesFolders() { string s = (); return s; } public void OpenMyPicturesFolders() { string s = (); (s); } public string GetStartMenuFolders() { string s = (); return s; } public void OpenStartMenuFolders() { string s = (); (s); } } }
I hope this article will be helpful to everyone's C# programming.