当前位置:编程学习 > C#/ASP.NET >>

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 打开记事本()    

补充:软件开发 , C# ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,