爱情 (1) 安装 (2) 北斗 (1) 毕业 (1) 变量 (1) 测绘局 (1) 测量 (2) 插件 (1) 查询 (1) 常用 (1) 成果转化 (1) 词汇 (1) 慈善 (1) 答辩 (2) 代码 (2) 电台 (1) 发泄 (1) 感悟 (4) 高程 (1) 搞笑 (5) 共产党 (1) 古诗词 (1) 管理 (1) 函数 (3) 绘图 (1) 加密 (1) 交际 (1) 教程 (4) 教育 (2) 解决 (4) 解密 (1) 精度 (1) 酒桌 (2) 开源 (2) 科技 (1) 科学 (1) 刻录 (1) 老外 (1) 励志 (5) 连续剧 (1) 恋爱 (1) 列表 (1) 领导 (1) 美食 (2) 名人 (3) 命令 (4) 区别 (1) 日记 (2) 软件 (12) 商业 (3) 时政 (1) 视频 (1) 数据 (1) 算法 (1) 投影 (2) 图论 (1) 网络 (1) 网站 (1) 卫星 (3) 未成年 (1) 慰问 (1) 文本 (1) 文件 (2) 下载 (4) 笑话 (2) 学习 (9) 遥感 (1) 疑问 (5) 营销 (1) 娱乐 (3) 源代码 (2) 政策 (1) 指导 (3) 智慧 (5) 主成分分析 (2) 抓图 (1) 专家 (1) 资料 (5) 字符串 (1) 最短路径 (1) 坐标 (1) baidu (3) Bernese (1) blog (2) c# (9) China (3) Dijkstra (1) DNS (1) doris (1) dos (1) excel (1) firefox (3) GAMIT (8) gcc (1) GIS (3) GMT (1) GPS (5) ITRF (1) linux (5) mapx (1) matlab (6) movie (4) music (3) oracle (2) pic (1) PPT (3) PROJ.4 (2) python (2) QQ (2) rinex (1) shell (2) sql (1) teqc (3) tools (1) tps (1) ubuntu (5) USA (1) website (1)

博客归档

2010年5月9日星期日

c# 后台调用teqc

使用c# 窗体程序 并建立了一个按钮控件
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
using System.Threading;

namespace TestExeWin1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
// try
{
Process myProcess=new Process();
myProcess.StartInfo.FileName = "cmd.exe";
myProcess.StartInfo.WorkingDirectory = "D:\\work";
myProcess.StartInfo.UseShellExecute = false;
myProcess.StartInfo.RedirectStandardError = true;
myProcess.StartInfo.RedirectStandardInput = true;
myProcess.StartInfo.RedirectStandardOutput = true;
myProcess.StartInfo.CreateNoWindow = true;
// myProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
myProcess.Start();
myProcess.StandardInput.WriteLine("teqc +qc wuhn0070.10o"); //ping 192.9.200.193
myProcess.StandardInput.WriteLine("exit");
// myProcess.CloseMainWindow();
string str = myProcess.StandardOutput.ReadToEnd();
MessageBox.Show(str);
// myProcess.StartInfo.UseShellExecute = false;

// myProcess = Process.Start("cmd.exe");
// myProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
//myProcess.StartInfo.CreateNoWindow = true;
// Display physical memory usage 5 times at intervals of 2 seconds.
for (int i = 0; i < 5; i++)
{
if (!myProcess.HasExited)
{
// Discard cached information about the process.
myProcess.Refresh();
// Print working set to console.
// Console.WriteLine("Physical Memory Usage: "
// + myProcess.WorkingSet.ToString());
MessageBox.Show("Physical Memory Usage: "
+ myProcess.WorkingSet.ToString());
// Wait 2 seconds.
Thread.Sleep(2000);
}
else
{
break;
}
}

// Close process by sending a close message to its main window.
// myProcess.CloseMainWindow();
// Free resources associated with process.
myProcess.Close();

}
// catch //(Exception e)
{
//Console.WriteLine("The following exception was raised: ");
// Console.WriteLine(e.Message);
// MessageBox.Show("The following exception was raised: ");
}

}
}
}

没有评论:

发表评论

浏览统计