程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> .NET網頁編程 >> C# >> C#入門知識 >> c#調用系統資源大集合

c#調用系統資源大集合

編輯:C#入門知識

//引入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 打開記事本()    

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved