解决方案 »
- 求教高手,将音频转化成二进制流,怎么转换回来?
- C# winform有没有像Webform的验证控件的东东啊?
- WinForm中的dataGrid转excel的问题!!急 !!!!
- 另外一个问题,不过很简单了,关于.Net + Access + SQL + Replace的问题。只能给50分了,因为我已经快没了……
- 水晶报表的问题
- 哥们我要疯了~~mdac版本问题~请高人指点~千万不要重装阿~~~在线等着给分
- SilverLight 绑定到ComboBox更新时候报错
- 在用printDocument打印报表时,怎么自定义纸张的大小?
- 窗体事件问题?
- 如何让richtextbox自动换行?
- 【在线急等】正则表达式提取
- 请问Form1_Paint和OnPaint的关系,以及所触发Paint 事件的先后次序?
正常情况下在dos运行应该是上面这个界面,输入“secureDataTool.exe USB0::2391::6056::US12345678::INSTR service snumber US12345678 mnumber MSOX3000A”后dos会输出一些内容,然后提示“Enter the serial numberr again to continue”,接着再次输入US12345678。现在情况是我做了个winform来做这个secureDataTool.exe的外壳,程序运行后只显示到这里我的后台代码如下,麻烦高手指点迷津,感激不尽啊,谢谢!
namespace secureDataToolGUI
{
public partial class Form1 : Form
{ Process p;
StreamWriter input; public Form1()
{
InitializeComponent(); p = new Process();
p.StartInfo.FileName = "cmd.exe";
p.StartInfo.UseShellExecute = false;
p.StartInfo.CreateNoWindow = true;
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.RedirectStandardOutput = true; p.OutputDataReceived += new DataReceivedEventHandler(p_OutputDataReceived); p.Start();
input = p.StandardInput;
p.BeginOutputReadLine();
} void p_OutputDataReceived(object sender, DataReceivedEventArgs e)
{
update(e.Data + Environment.NewLine);
} private void button1_Click(object sender, EventArgs e)
{
input.WriteLine(textBox1.Text);
if (textBox1.Text.Contains("\\"))
{
textBox1.Text = "secureDataTool.exe " + label1.Text + textBox3.Text + label2.Text + textBox4.Text + label3.Text + textBox5.Text + label4.Text + textBox6.Text + label5.Text + textBox7.Text;
button1.Text = "RUN";
}
else
{
textBox1.Text = "";
button1.Text = "Load Program";
}
} //申明delegate更新数据
delegate void updateDelegate(string msg);
void update(string msg)
{
if (this.InvokeRequired)
Invoke(new updateDelegate(update), new object[] { msg });
else
{
textBox2.Text += msg;
textBox2.SelectionStart = textBox2.Text.Length - 1;
textBox2.ScrollToCaret();
}
}
//关闭GUI窗口
private void Form1_FormClosed(object sender, FormClosedEventArgs e)
{
p.Close();
}
//打开文件浏览对话框
private void button2_Click(object sender, EventArgs e)
{
this.openFileDialog1.ShowDialog();
}
//获取文件路径,将路径定位到文件所在位置
private void openFileDialog1_FileOk(object sender, CancelEventArgs e)
{
string filepath = openFileDialog1.FileName;
int fileposition = filepath.LastIndexOf("\\");
textBox1.Text = "cd " + filepath.Substring(0, fileposition);
}
#region
//private void textBox3_KeyPress(object sender, KeyPressEventArgs e)
//{
// if (!Char.IsNumber(e.KeyChar) && Convert.ToInt32(e.KeyChar) != 8)
// {
// e.Handled = true;
// }
//} //private void textBox4_KeyPress(object sender, KeyPressEventArgs e)
//{
// if (!Char.IsNumber(e.KeyChar) && Convert.ToInt32(e.KeyChar) != 8)
// {
// e.Handled = true;
// }
//} //private void textBox5_Leave(object sender, EventArgs e)
//{
// System.Text.RegularExpressions.Regex myregex = new System.Text.RegularExpressions.Regex("[A-Z]{2}[0-9]{8}");
// if (!myregex.IsMatch(textBox5.Text))
// {
// MessageBox.Show("输入格式有误!");
// textBox5.Text = "";
// }
//} //private void textBox6_Leave(object sender, EventArgs e)
//{
// System.Text.RegularExpressions.Regex myregex = new System.Text.RegularExpressions.Regex("[A-Z]{2}[0-9]{8}");
// if (!myregex.IsMatch(textBox6.Text))
// {
// MessageBox.Show("输入格式有误!");
// textBox6.Text = "";
// }
//}
#endregion
}
}