CQ-CSER

计算机爱好者

VISUAL C#系列

Posted on | 四月 11, 2010 | 1 Comment

  private void button2_Click(object sender, EventArgs e)
        {//获取Cmd命令行窗口中显示的内容
            Process MyProcess = new Process();
            //设定程序名
            MyProcess.StartInfo.FileName = “cmd.exe”;
            //关闭Shell的使用
            MyProcess.StartInfo.UseShellExecute = false;
            //重定向标准输入
            MyProcess.StartInfo.RedirectStandardInput = true;
            //重定向标准输出
            MyProcess.StartInfo.RedirectStandardOutput = true;
            //重定向错误输出
            MyProcess.StartInfo.RedirectStandardError = true;
            //设置不显示窗口
            MyProcess.StartInfo.CreateNoWindow = true;
            //执行DOS命令
            MyProcess.Start();
            MyProcess.StandardInput.WriteLine(“Dir C:\\”);
            MyProcess.StandardInput.WriteLine(“exit”);
            //从输出流获取命令执行结果,
            string MyInfo = MyProcess.StandardOutput.ReadToEnd();
            MessageBox.Show(MyInfo, “信息提示”, MessageBoxButtons.OK, MessageBoxIcon.Information);
        }

        private void button3_Click(object sender, EventArgs e)
        {//同步加载并播放声音文件
            SoundPlayer MyPlayer= new SoundPlayer();
            string MyFileName = Application.StartupPath + “\\WindowsXPStart.wav“;
            MyPlayer.SoundLocation = MyFileName;
            MyPlayer.Load();
            MyPlayer.PlaySync();       
        }

        private void button4_Click(object sender, EventArgs e)
        {//异步加载并播放声音文件
            SoundPlayer MyPlayer = new SoundPlayer();
            string MyFileName = Application.StartupPath + “\\WindowsXPStart.wav“;
            MyPlayer.SoundLocation = MyFileName;
           MyPlayer.LoadAsync();
            MyPlayer.Play();
        }

相关文章:

  1. 启动控制面板各选项:c#
  2. wmi查询管理:c#
  3. asp.net的几种页面传值方法
  4. C#调用打印机信息
  5. 调用rundll32等实现各种功能:c#

评论|Comments

One Response to “VISUAL C#系列”

  1. cq
    五月 2nd, 2010 @ 11:05

    /************************************************
    * Left Sidebar *
    ************************************************/

    #l_sidebar {
    float: right;
    width: 203px;
    margin: 40px 0px 0px 0px;
    padding: 0px 19px 20px 19px;
    border-left: 1px solid #E2DDDE;
    font:11px/18px Verdana, Arial, Helvetica, sans-serif;
    }

    #l_sidebar ul {
    list-style: none;
    margin: 0px;
    padding: 0px;
    }

    #l_sidebar ul li {
    background:transparent url(“images/bullet.gif”) 0px 11px no-repeat; /* 0px = horizontal position for left, 6px = vertical position from top */
    display: block;
    padding: 4px 0px 4px 10px;
    margin: 0px;
    }

    #l_sidebar a:link, #l_sidebar a:visited { color:#444; text-decoration:none; outline:none; }
    #l_sidebar a:hover, #l_sidebar a:active { color:#444; text-decoration:underline; outline:none; }

    #l_sidebar p{
    padding: 3px 0px 0px 0px;
    margin: 0px;
    line-height: 20px;
    }

    #l_sidebar li {list-style: none; }

留言|Leave a Reply





  • Archives

  • SUNSHINE

  • About

    本博客采用创作共用版权协议,要求署名、非商业用途和保持一致. 转载本博客内容也遵循“署名-非商业用途-保持一致”的创作共用协议.

    订阅

    Search

    Admin