首先:編寫一個調用系統資源的大類,代碼如下using System;using System.Collections.Generic;using System.Text;using System.Runtime.InteropServices;using System.Diagnostics;using System.IO;namespace DOS工具箱{ public class 調用系統資源 { //引入API函數 [DllImportAttribute("user32.dll")] public static extern int FindWindow(string ClassName,string WindowName); [DllImport("user32.dll")] public static extern int ShowWindow(int handle, int cmdShow); [DllImport("winmm.dll", EntryPoint = "mciSendString", CharSet = CharSet.Auto)] public static extern int mciSendString(string lpstrCommand, string lpstrReturnstring, int uReturnLength, int hwndCallback); private const int SW_HIDE=0;//API參數表示隱藏視窗 private const int SW_SHOW=5;//API參數表示用當前的大小和位置顯示視窗 public static void 彈出光碟機() { mciSendString("set CDAudio door open", null, 127, 0); } public static void 關閉光碟機() { mciSendString("set CDAudio door closed", null, 127, 0); } public static void 開啟C盤() { Process.Start("c:\\"); } public static void 開啟D盤() { Process.Start("d:\\"); } public static void 開啟E盤() { Process.Start("e:\\"); } public static void 開啟F盤() { Process.Start("f:\\"); } public static void 開啟指定盤(string hardpath) { Process.Start(hardpath); } public static void 開啟Word() { Process.Start(@"C:\Program Files\Microsoft Office\OFFICE11\winword.exe"); } public static void 開啟Excel() { Process.Start(@"C:\Program Files\Microsoft Office\OFFICE11\excel.exe"); } public static void 開啟Access() { Process.Start(@"C:\Program Files\Microsoft Office\OFFICE11\msaccess.exe"); } public static void 開啟PowerPoint() { Process.Start(@"C:\Program Files\Microsoft Office\OFFICE11\powerpnt.exe"); } public static void 開啟OutLook() { Process.Start(@"C:\Program Files\Microsoft Office\OFFICE11\outlook.exe"); } public static void 開啟記事本() { Process.Start("notepad.exe"); } public static void 開啟計算機() { Process.Start("calc.exe"); } public static void 開啟DOS命令視窗() { Process.Start("cmd.exe"); } public static void 開啟註冊表() { Process.Start("regedit.exe"); } public static void 開啟畫圖板() { Process.Start("mspaint.exe"); } public static void 開啟寫字板() { Process.Start("write.exe"); } public static void 開啟播放器() { Process.Start("mplayer2.exe"); } public static void 開啟資源管理員() { Process.Start("explorer.exe"); } public static void 開啟工作管理員() { Process.Start("taskmgr.exe"); } public static void 開啟事件檢視器() { Process.Start("eventvwr.exe"); } public static void 開啟系統資訊() { Process.Start("winmsd.exe"); } public static void 開啟備份還原() { Process.Start("ntbackup.exe"); } public static void 開啟Windows版本() { Process.Start("winver.exe"); } public static void 開啟控制台() { Process.Start("rundll32.exe", "shell32.dll,Control_RunDLL"); } public static void 開啟控制台輔助選項鍵盤() { Process.Start("rundll32.exe", "shell32.dll,Control_RunDLL access.cpl,,1"); } public static void 開啟控制台輔助選項聲音() { Process.Start("rundll32.exe", "shell32.dll,Control_RunDLL access.cpl,,2"); } public static void 開啟控制台輔助選項顯示() { Process.Start("rundll32.exe", "shell32.dll,Control_RunDLL access.cpl,,3"); } public static void 開啟控制台輔助選項滑鼠() { Process.Start("rundll32.exe", "shell32.dll,Control_RunDLL access.cpl,,4"); } public static void 開啟控制台輔助選項常規() { Process.Start("rundll32.exe", "shell32.dll,Control_RunDLL access.cpl,,5"); } public static void 開啟控制台添加新硬體嚮導() { Process.Start("rundll32.exe", "shell32.dll,Control_RunDLL sysdm.cpl @1"); } public static void 開啟控制台添加新印表機嚮導() { Process.Start("rundll32.exe", "shell32.dll,SHHelpShortcuts_RunDLL AddPrinter"); } public static void 開啟控制台添加刪除程式安裝卸載面板() { Process.Start("rundll32.exe", "shell32.dll,shell32.dll,Control_RunDLL appwiz.cpl,,1"); } public static void 開啟控制台添加刪除程式安裝Windows面板() { Process.Start("rundll32.exe", "shell32.dll,shell32.dll,Control_RunDLL appwiz.cpl,,2"); } public static void 開啟控制台添加刪除程式啟動盤面板() { Process.Start("rundll32.exe", "shell32.dll,shell32.dll,Control_RunDLL appwiz.cpl,,3"); } public static void 開啟建立捷徑對話方塊() { Process.Start("rundll32.exe"," appwiz.cpl,NewLinkHere %1"); } public static void 開啟日期時間選項() { Process.Start("rundll32.exe"," shell32.dll,Control_RunDLL timedate.cpl,,0"); } public static void 開啟時區選項() { Process.Start("rundll32.exe", " shell32.dll,Control_RunDLL timedate.cpl,,1"); } public static void 建立公事包() { Process.Start("rundll32.exe"," syncui.dll,Briefcase_Create"); } public static void 開啟複製軟碟視窗() { Process.Start("rundll32.exe"," diskcopy.dll,DiskCopyRunDll"); } public static void 開啟建立撥號連線() { Process.Start("rundll32.exe"," rnaui.dll,RnaWizard"); } public static void 開啟顯示內容背景() { Process.Start("rundll32.exe"," shell32.dll,Control_RunDLL desk.cpl,,0"); } public static void 開啟顯示內容螢幕保護裝置() { Process.Start("rundll32.exe", " shell32.dll,Control_RunDLL desk.cpl,,1"); } public static void 開啟顯示內容外觀() { Process.Start("rundll32.exe", " shell32.dll,Control_RunDLL desk.cpl,,2"); } public static void 開啟顯示內容屬性() { Process.Start("rundll32.exe", " shell32.dll,Control_RunDLL desk.cpl,,3"); } //public static void 開啟Windows字型檔案夾() //{ // Process.Start("rundll32.exe"," shell32.dll,SHHelpShortcuts_RunDLL FontsFolder"); //}