导航:业界 | 认证 | 工具 | 图形 | 技术 | 系统 | 网络 | 办公 | 网页 | 文摘 | 动画
您当前的位置:diva8.com -> I T -> 技术 -> .Net专栏 -> I T内容
栏目导航
· .Net专栏 · Script
· ASP学院 · PHP学院
· Web服务器 · CGI学院
· XML学院 · SQL学院
· JSP学院 · SMS学院
热门I T
· [组图] 音频后期处理Adobe ...
· [组图] Photoshop--照片处理...
· [组图] 廉颇老矣?IE7.0 Bet...
· [图文] DuDu下载加速器推出...
· [组图] 清晰还原!Photoshop...
· [组图] 用photoshop给图片祛...
· [组图] DuDu 下载加速器试用...
· [组图] 新春特别版:PPLIVE...
· [图文] 让查找更方便些 腾讯...
· [组图] 廉颇老矣?IE7.0 Bet...
相关I T
· 做一个Win98“无驱”...
做一个Windows窗体版的DOS分析器
作者:Admin  来源:齐昌网络  发布时间:2004-5-25 14:55:55  发布人:qichang

减小字体 增大字体



using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Diagnostics;

namespace EzoneDOSApp
{
///
/// Form1 的摘要说明。
///
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.TextBox txtCmd;
private System.Windows.Forms.Button btnOK;
private System.Windows.Forms.RichTextBox rtbResult;
///
/// 必需的设计器变量。
///
private System.ComponentModel.Container components = null;

private Process ProcessCmdObject;

public Form1()
{
//
// Windows 窗体设计器支持所必需的
//


InitializeComponent();

//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
ProcessCmdObject=new Process();

ProcessCmdObject.StartInfo.FileName="cmd.exe";

ProcessCmdObject.StartInfo.UseShellExecute=false;

ProcessCmdObject.StartInfo.RedirectStandardInput=true;

ProcessCmdObject.StartInfo.RedirectStandardOutput=true;

ProcessCmdObject.StartInfo.RedirectStandardError=true;

ProcessCmdObject.StartInfo.CreateNoWindow=true;

ProcessCmdObject.Start();

}///
/// 清理所有正在使用的资源。
///
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows 窗体设计器生成的代码

///
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
///
private void InitializeComponent()
{
this.txtCmd = new System.Windows.Forms.TextBox();
this.btnOK = new System.Windows.Forms.Button();
this.rtbResult = new System.Windows.Forms.RichTextBox();
this.SuspendLayout();
//
// txtCmd
//
this.txtCmd.Location = new System.Drawing.Point(0, 0);
this.txtCmd.Name = "txtCmd";
this.txtCmd.Size = new System.Drawing.Size(448, 21);
this.txtCmd.TabIndex = 0;
this.txtCmd.Text = "";
//
// btnOK
//
this.btnOK.Location = new System.Drawing.Point(456, 0);
this.btnOK.Name = "btnOK";
this.btnOK.TabIndex = 1;
this.btnOK.Text = "确认";
this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
//
// rtbResult
//
this.rtbResult.Location = new System.Drawing.Point(0, 24);
this.rtbResult.Name = "rtbResult";
this.rtbResult.Size = new System.Drawing.Size(536, 424);
this.rtbResult.TabIndex = 2;
this.rtbResult.Text = "";
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(536, 445);
this.Controls.Add(this.rtbResult);
this.Controls.Add(this.btnOK);
this.Controls.Add(this.txtCmd);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.MaximizeBox = false;
this.Name = "Form1";
this.Text = "DOS分析器 - 亿众国际";
this.Closing += new System.ComponentModel.CancelEventHandler(this.Form1_Closing);
this.ResumeLayout(false);

}
#endregion

///
/// 应用程序的主入口点。
///
[STAThread]

static void Main()
{
Application.Run(new Form1());
}

private void btnOK_Click(object sender, System.EventArgs e)
{
ProcessCmdObject=new Process();

ProcessCmdObject.StartInfo.FileName="cmd.exe";

ProcessCmdObject.StartInfo.UseShellExecute=false;

ProcessCmdObject.StartInfo.RedirectStandardInput=true;

ProcessCmdObject.StartInfo.RedirectStandardOutput=true;

ProcessCmdObject.StartInfo.RedirectStandardError=true;

ProcessCmdObject.StartInfo.CreateNoWindow=true;

ProcessCmdObject.Start();

ProcessCmdObject.StandardInput.WriteLine(this.txtCmd.Text.Trim());

ProcessCmdObject.StandardInput.WriteLine("exit");

this.rtbResult.Text=ProcessCmdObject.StandardOutput.ReadToEnd()+ProcessCmdObject.StandardError.ReadToEnd();
}

private void Form1_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
}
}
}


Author: stardicky
E-mail: stardicky@hotmail.com
QQNumber: 9531511
CompanyName: Ezone International
Class: HBS-0308
title: 做一个Windows窗体版的DOS分析器


[] [返回上一页] [打 印] [收 藏]
下一篇I T:XML相关技术资料
∷相关I T评论∷    (评论内容只代表网友观点,与本站立场无关!) [更多评论...]
关于本站 - 网站帮助 - 广告合作 - 下载声明 - 友情连接 - 网站地图 - 在线人数:
diva8.com Copyright © 2001-2006 diva8.com All Rights Reserved .粤ICP备05014750号