c#控制台模拟dos_C#实现的调用DOS命令操作类实例

/***********************************

* All Rights Reserved , Copyright (C) 2012 , EricHu.

* 作 者: EricHu

* 创建时间: 2012-5-4 15:29:35

***********************************/

using System;

using System.Diagnostics;

using System.Runtime.InteropServices;

namespace PlatForm.Utilities

{

///

///

/// DosHelper

/// Dos常用操作类

///

///

public class DosHelper

{

//引入API函数

[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);

private const int SW_HIDE = 0;//API参数表示隐藏窗口

private const int SW_SHOW = 5;//API参数表示用当前的大小和位置显示窗口

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 打开资源管理器()

{

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值