中文字幕av专区_日韩电影在线播放_精品国产精品久久一区免费式_av在线免费观看网站

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

如何實現調用DOS命令的C#操作類

發布時間:2021-10-21 13:48:19 來源:億速云 閱讀:141 作者:小新 欄目:編程語言

這篇文章給大家分享的是有關如何實現調用DOS命令的C#操作類的內容。小編覺得挺實用的,因此分享給大家做個參考,一起跟隨小編過來看看吧。

將做工程過程中經常用到的一些代碼備份一次,如下代碼是關于一個用來調用DOS命令的C#操作類的代碼,應該是對大家有較大用途。

using System;
using System.Diagnostics;
using System.Runtime.InteropServices;

namespace PlatForm.Utilities
{
    public class DosHelper
    {
        [DllImportAttribute("user32.dll")]
        private static extern int FindWindow(string ClassName, string WindowName);
        [DllImport("user32.dll")]
        private static extern int ShowWindow(int handle, int cmdShow);
        [DllImport("winmm.dll", EntryPoint = "mciSendString", CharSet = CharSet.Auto)]
        private static extern int mciSendString(string lpstrCommand, string lpstrReturnstring, int uReturnLength, int hwndCallback);

        public void 彈出光驅()
        {
            mciSendString("set CDAudio door open", null, 127, 0);
        }

        public void 關閉光驅()
        {
            mciSendString("set CDAudio door closed", null, 127, 0);
        }

        public void 打開C盤()
        {
            Process.Start("c:");
        }

        public void 打開D盤()
        {
            Process.Start("d:");
        }

        public void 打開E盤()
        {
            Process.Start("e:");
        }

        public void 打開F盤()
        {
            Process.Start("f:");
        }

        public void 打開指定盤(string hardpath)
        {
            Process.Start(hardpath);
        }

        public void 打開Word()
        {
            Process.Start(@"C:Program FilesMicrosoft OfficeOFFICE11winword.exe");
        }

        public void 打開Excel()
        {
            Process.Start(@"C:Program FilesMicrosoft OfficeOFFICE11excel.exe");
        }

        public void 打開Access()
        {
            Process.Start(@"C:Program FilesMicrosoft OfficeOFFICE11msaccess.exe");
        }

        public void 打開PowerPoint()
        {
            Process.Start(@"C:Program FilesMicrosoft OfficeOFFICE11powerpnt.exe");
        }

        public void 打開OutLook()
        {
            Process.Start(@"C:Program FilesMicrosoft OfficeOFFICE11outlook.exe");
        }

        public void 打開記事本()
        {
            Process.Start("notepad.exe");
        }

        public void 打開計算器()
        {
            Process.Start("calc.exe");
        }

        public void 打開DOS命令窗口()
        {
            Process.Start("cmd.exe");
        }

        public void 打開注冊表()
        {
            Process.Start("regedit.exe");
        }

        public void 打開畫圖板()
        {
            Process.Start("mspaint.exe");
        }

        public void 打開寫字板()
        {
            Process.Start("write.exe");
        }

        public void 打開播放器()
        {
            Process.Start("mplayer2.exe");
        }

        public void 打開資源管理器()
        {
            Process.Start("explorer.exe");
        }

        public void 打開任務管理器()
        {
            Process.Start("taskmgr.exe");
        }

        public void 打開事件查看器()
        {
            Process.Start("eventvwr.exe");
        }

        public void 打開系統信息()
        {
            Process.Start("winmsd.exe");
        }

        public void 打開備份還原()
        {
            Process.Start("ntbackup.exe");
        }

        public void 打開Windows版本()
        {
            Process.Start("winver.exe");
        }

        public void 打開控制面板()
        {
            Process.Start("rundll32.exe", "shell32.dll,Control_RunDLL");
        }

        public void 打開控制面板輔助選項鍵盤()
        {
            Process.Start("rundll32.exe", "shell32.dll,Control_RunDLL access.cpl,,1");
        }

        public void 打開控制面板輔助選項聲音()
        {
            Process.Start("rundll32.exe", "shell32.dll,Control_RunDLL access.cpl,,2");
        }

        public void 打開控制面板輔助選項顯示()
        {
            Process.Start("rundll32.exe", "shell32.dll,Control_RunDLL access.cpl,,3");
        }

        public void 打開控制面板輔助選項鼠標()
        {
            Process.Start("rundll32.exe", "shell32.dll,Control_RunDLL access.cpl,,4");
        }

        public void 打開控制面板輔助選項常規()
        {
            Process.Start("rundll32.exe", "shell32.dll,Control_RunDLL access.cpl,,5");
        }

        public void 打開控制面板添加新硬件向導()
        {
            Process.Start("rundll32.exe", "shell32.dll,Control_RunDLL sysdm.cpl @1");
        }

        public void 打開控制面板添加新打印機向導()
        {
            Process.Start("rundll32.exe", "shell32.dll,SHHelpShortcuts_RunDLL AddPrinter");
        }

        public void 打開控制面板添加刪除程序安裝卸載面板()
        {
            Process.Start("rundll32.exe", "shell32.dll,shell32.dll,Control_RunDLL appwiz.cpl,,1");
        }

        public void 打開控制面板添加刪除程序安裝Windows面板()
        {
            Process.Start("rundll32.exe", "shell32.dll,shell32.dll,Control_RunDLL appwiz.cpl,,2");
        }

        public void 打開控制面板添加刪除程序啟動盤面板()
        {
            Process.Start("rundll32.exe", "shell32.dll,shell32.dll,Control_RunDLL appwiz.cpl,,3");
        }

        public void 打開建立快捷方式對話框()
        {
            Process.Start("rundll32.exe", " appwiz.cpl,NewLinkHere %1");
        }

        public void 打開日期時間選項()
        {
            Process.Start("rundll32.exe", " shell32.dll,Control_RunDLL timedate.cpl,,0");
        }

        public void 打開時區選項()
        {
            Process.Start("rundll32.exe", " shell32.dll,Control_RunDLL timedate.cpl,,1");
        }

        public void 建立公文包()
        {
            Process.Start("rundll32.exe", " syncui.dll,Briefcase_Create");
        }

        public void 打開復制軟碟窗口()
        {
            Process.Start("rundll32.exe", " diskcopy.dll,DiskCopyRunDll");
        }

        public void 打開新建撥號連接()
        {
            Process.Start("rundll32.exe", " rnaui.dll,RnaWizard");
        }

        public void 打開顯示屬性背景()
        {
            Process.Start("rundll32.exe", " shell32.dll,Control_RunDLL desk.cpl,,0");
        }

        public void 打開顯示屬性屏幕保護()
        {
            Process.Start("rundll32.exe", " shell32.dll,Control_RunDLL desk.cpl,,1");
        }

        public void 打開顯示屬性外觀()
        {
            Process.Start("rundll32.exe", " shell32.dll,Control_RunDLL desk.cpl,,2");
        }

        public void 打開顯示屬性屬性()
        {
            Process.Start("rundll32.exe", " shell32.dll,Control_RunDLL desk.cpl,,3");
        }

        public void 打開格式化對話框()
        {
            Process.Start("rundll32.exe", " shell32.dll,SHFormatDrive");
        }

        public void 打開控制面板游戲控制器一般()
        {
            Process.Start("rundll32.exe", " shell32.dll,Control_RunDLL joy.cpl,,0");
        }

        public void 打開控制面板游戲控制器進階()
        {
            Process.Start("rundll32.exe", " shell32.dll,Control_RunDLL joy.cpl,,1");
        }

        public void 打開控制面板鍵盤屬性速度()
        {
            Process.Start("rundll32.exe", " shell32.dll,Control_RunDLL main.cpl @1");
        }

        public void 打開控制面板鍵盤屬性語言()
        {
            Process.Start("rundll32.exe", " shell32.dll,Control_RunDLL main.cpl @1,,1");
        }

        public void 打開Windows打印機檔案夾()
        {
            Process.Start("rundll32.exe", " shell32.dll,Control_RunDLL main.cpl @2");
        }

        public void 打開Windows字體檔案夾()
        {
            Process.Start("rundll32.exe", " shell32.dll,Control_RunDLL main.cpl @3");
        }

        public void 打開控制面板輸入法屬性()
        {
            Process.Start("rundll32.exe", " shell32.dll,Control_RunDLL main.cpl @4");
        }

        public void 打開添加新調制解調器向導()
        {
            Process.Start("rundll32.exe", " shell32.dll,Control_RunDLL modem.cpl,,add");
        }

        public void 打開控制面板多媒體屬性音頻()
        {
            Process.Start("rundll32.exe", " shell32.dll,Control_RunDLL mmsys.cpl,,0");
        }

        public void 打開控制面板多媒體屬性視頻()
        {
            Process.Start("rundll32.exe", " shell32.dll,Control_RunDLL mmsys.cpl,,1");
        }

        public void 打開控制面板多媒體屬性MIDI()
        {
            Process.Start("rundll32.exe", " shell32.dll,Control_RunDLL mmsys.cpl,,2");
        }

        public void 打開控制面板多媒體屬性CD音樂()
        {
            Process.Start("rundll32.exe", " shell32.dll,Control_RunDLL mmsys.cpl,,3");
        }

        public void 打開控制面板多媒體屬性設備()
        {
            Process.Start("rundll32.exe", " shell32.dll,Control_RunDLL mmsys.cpl,,4");
        }

        public void 打開控制面板聲音()
        {
            Process.Start("rundll32.exe", " shell32.dll,Control_RunDLL mmsys.cpl @1");
        }

        public void 打開控制面板網絡()
        {
            Process.Start("rundll32.exe", " shell32.dll,Control_RunDLL netcpl.cpl");
        }

        public void 打開控制面板密碼()
        {
            Process.Start("rundll32.exe", " shell32.dll,Control_RunDLL password.cpl");
        }

        public void 打開控制面板電源管理()
        {
            Process.Start("rundll32.exe", " shell32.dll,Control_RunDLL powercfg.cpl");
        }

        public void 打開控制面板區域設置屬性區域設置()
        {
            Process.Start("rundll32.exe", " shell32.dll,Control_RunDLL intl.cpl,,0");
        }

        public void 打開控制面板區域設置屬性數字選項()
        {
            Process.Start("rundll32.exe", " shell32.dll,Control_RunDLL intl.cpl,,1");
        }

        public void 打開控制面板區域設置屬性貨幣選項()
        {
            Process.Start("rundll32.exe", " shell32.dll,Control_RunDLL intl.cpl,,2");
        }

        public void 打開控制面板區域設置屬性時間選項()
        {
            Process.Start("rundll32.exe", " shell32.dll,Control_RunDLL intl.cpl,,3");
        }

        public void 打開控制面板區域設置屬性日期選項()
        {
            Process.Start("rundll32.exe", " shell32.dll,Control_RunDLL intl.cpl,,4");
        }

        public void 打開ODBC數據源管理器()
        {
            Process.Start("rundll32.exe", " shell32.dll,Control_RunDLL odbccp32.cpl");
        }

        public void 打開控制面板系統屬性常規()
        {
            Process.Start("rundll32.exe", " shell32.dll,Control_RunDLL sysdm.cpl,,0");
        }

        public void 打開控制面板系統屬性設備管理器()
        {
            Process.Start("rundll32.exe", " shell32.dll,Control_RunDLL sysdm.cpl,,1");
        }

        public void 打開控制面板系統屬性硬件配置()
        {
            Process.Start("rundll32.exe", " shell32.dll,Control_RunDLL sysdm.cpl,,2");
        }

        public void 打開控制面板系統屬性性能()
        {
            Process.Start("rundll32.exe", " shell32.dll,Control_RunDLL sysdm.cpl,,3");
        }

        一小時后強行關機 用強行主要怕有些程序卡住 關不了機 
        -s 關機 
        -r重啟 
        -f強行 
        -t 時間 
        -a 取消關機 
        -l 注銷 

        public void 關閉并重啟計算機()
        {
            Process.Start("shutdown.exe", "-r");
        }

        public void 關閉計算機()
        {
            Process.Start("shutdown.exe", "-s -f");
        }
        public void 關閉計算機(string time)
        {
            string s = "-s -t " + time;
            Process.Start("shutdown.exe", s);
        }

        public void 注銷計算機()
        {
            Process.Start("shutdown.exe", "-l");
        }

        public void 撤銷關閉計算機()
        {
            Process.Start("shutdown.exe", "-a");
        }

        public void 打開桌面主旨面板()
        {
            Process.Start("rundll32.exe", " shell32.dll,Control_RunDLL themes.cpl");
        }

        public void 打開網址(string address)
        {
            Process.Start(address);
        }

        public void 運行程序(string name)
        {
            Process.Start(name);
        }

        public void 顯示任務欄()
        {
            ShowWindow(FindWindow("Shell_TrayWnd", null), SW_SHOW);
        }

        public void 隱藏任務欄()
        {
            ShowWindow(FindWindow("Shell_TrayWnd", null), SW_HIDE);
        }

        public void 發送郵件(string address)
        {
            string s = "mailto:" + address;
            Process.Start(s);
        }

        public void 發送郵件()
        {
            Process.Start("mailto:80368704@qq.com");
        }

        public string 獲取系統文件夾()
        {
            string s = Environment.GetFolderPath(Environment.SpecialFolder.System);
            return s;
        }

        public void 打開系統文件夾()
        {
            string s = Environment.GetFolderPath(Environment.SpecialFolder.System);
            Process.Start(s);
        }

        public string 獲取ProgramFiles目錄()
        {
            string s = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);
            return s;
        }

        public void 打開ProgramFiles目錄()
        {
            string s = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);
            Process.Start(s);
        }

        public string 獲取邏輯桌面()
        {
            string s = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
            return s;
        }

        public void 打開邏輯桌面()
        {
            string s = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
            Process.Start(s);
        }

        public string 獲取啟動程序組()
        {
            string s = Environment.GetFolderPath(Environment.SpecialFolder.Startup);
            return s;
        }

        public void 打開啟動程序組()
        {
            string s = Environment.GetFolderPath(Environment.SpecialFolder.Startup);
            Process.Start(s);
        }

        public string 獲取Cookies文件夾()
        {
            string s = Environment.GetFolderPath(Environment.SpecialFolder.Cookies);
            return s;
        }

        public void 打開Cookies文件夾()
        {
            string s = Environment.GetFolderPath(Environment.SpecialFolder.Cookies);
            Process.Start(s);
        }

        public string 獲取Internet歷史文件夾()
        {
            string s = Environment.GetFolderPath(Environment.SpecialFolder.History);
            return s;
        }

        public void 打開Internet歷史文件夾()
        {
            string s = Environment.GetFolderPath(Environment.SpecialFolder.History);
            Process.Start(s);
        }

        public string 獲取我的電腦文件夾()
        {
            string s = Environment.GetFolderPath(Environment.SpecialFolder.MyComputer);
            return s;
        }

        public void 打開我的電腦文件夾()
        {
            string s = Environment.GetFolderPath(Environment.SpecialFolder.MyComputer);
            Process.Start(s);
        }

        public string 獲取MyMusic文件夾()
        {
            string s = Environment.GetFolderPath(Environment.SpecialFolder.MyMusic);
            return s;
        }

        public void 打開MyMusic文件夾()
        {
            string s = Environment.GetFolderPath(Environment.SpecialFolder.MyMusic);
            Process.Start(s);
        }

        public string 獲取MyPictures文件夾()
        {
            string s = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures);
            return s;
        }

        public void 打開MyPictures文件夾()
        {
            string s = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures);
            Process.Start(s);
        }

        public string 獲取StartMenu文件夾()
        {
            string s = Environment.GetFolderPath(Environment.SpecialFolder.StartMenu);
            return s;
        }

        public void 打開StartMenu文件夾()
        {
            string s = Environment.GetFolderPath(Environment.SpecialFolder.StartMenu);
            Process.Start(s);
        }  
    }
}

感謝各位的閱讀!關于“如何實現調用DOS命令的C#操作類”這篇文章就分享到這里了,希望以上內容可以對大家有一定的幫助,讓大家可以學到更多知識,如果覺得文章不錯,可以把它分享出去讓更多的人看到吧!

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

doc
AI

武山县| 临海市| 社会| 丹阳市| 临沂市| 太仆寺旗| 大宁县| 泸水县| 建始县| 定西市| 利津县| 祁东县| 西青区| 昭通市| 含山县| 福鼎市| 柞水县| 高邮市| 龙山县| 贵港市| 襄城县| 潼南县| 米脂县| 平和县| 乌鲁木齐市| 平定县| 沁水县| 紫阳县| 乌苏市| 易门县| 武陟县| 肇东市| 万荣县| 平安县| 卫辉市| 沛县| 定西市| 内江市| 敖汉旗| 高清| 蚌埠市|