×

winexec返回值 启动 程序

c# 怎么 启动指定 目录下的 EXE 程序(这个程序是JAVA 的控制台程序)?什么意思源程序

admin admin 发表于2022-07-10 20:52:57 浏览129 评论0

抢沙发发表评论

c# 怎么 启动指定 目录下的 EXE 程序(这个程序是JAVA 的控制台程序)


C#之启动指定目录下的程序,我会JAVA,给你C#的
Process debug = new Process(); //创建新的进程
//设置进程信息
debug.StartInfo.FileName = 《string》filePath;//程序路径
debug.StartInfo.Arguments = 《string》arg;//程序参数
debug.StartInfo.UseShellExecute = false;//
debug.StartInfo.CreateNoWindow = true;//是否创建新窗口true为不创建
debug.Start();//启动进程
debug.Close();//关闭进程

什么意思源程序


源代码就是编写程序的代码,没有经过编译运行的代码。不开放源代码就是不希望别人能够看到系统的实现过程,任何bug和维护都是内部人员完成。这种不开放的源代码一般都是有一定的专利技术在里面,不希望被外人看见、借用。开放的源代码的系统更稳定,因为所有的开发者都可以看见这个系统的代码。可以及时提交关于系统的bug修复建议,Linux是一个代表,所以经过多年的努力,现在的Linux更适合开发者开发应用。

求助JAVA程序设计题答案


import java.awt.BorderLayout;
import java.awt.Button;
import java.awt.Container;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.WindowConstants;

public class Caculator extends JFrame implements ActionListener,KeyListener{
private JTextField tf=new JTextField();
private float x=0;
private float y=0;
private int code=0;
private boolean enable;
private boolean first;
private String str=““;
public Caculator(){
Container ct=this.getContentPane();
this.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
tf.setHorizontalAlignment(JTextField.RIGHT);
//tf.setText(“0“);
enable=true;
first=true;
ct.add(tf,BorderLayout.NORTH);
JPanel panel=new JPanel();
panel.setLayout(new GridLayout(4,4));
this.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
if(JOptionPane.YES_OPTION==JOptionPane.showConfirmDialog(Caculator.this,“确定要关闭程序吗?“,“提示“,JOptionPane.OK_CANCEL_OPTION,JOptionPane.QUESTION_MESSAGE)){
e.getWindow().setVisible(false);
e.getWindow().dispose();
System.exit(0);
}

}
});
Button btn=null;
btn=new Button(“1“);
panel.add(btn);
btn.addActionListener(this);
btn.addKeyListener(this);
btn=new Button(“2“);
panel.add(btn);
btn.addActionListener(this);
btn.addKeyListener(this);
btn=new Button(“3“);
panel.add(btn);
btn.addActionListener(this);
btn.addKeyListener(this);
btn=new Button(“+“);
panel.add(btn);
btn.addActionListener(this);
btn.addKeyListener(this);
btn=new Button(“4“);
panel.add(btn);
btn.addActionListener(this);
btn.addKeyListener(this);
btn=new Button(“5“);
panel.add(btn);
btn.addActionListener(this);
btn.addKeyListener(this);
btn=new Button(“6“);
panel.add(btn);
btn.addActionListener(this);
btn.addKeyListener(this);
btn=new Button(“-“);
panel.add(btn);
btn.addActionListener(this);
btn.addKeyListener(this);
btn=new Button(“7“);
panel.add(btn);
btn.addActionListener(this);
btn.addKeyListener(this);
btn=new Button(“8“);
panel.add(btn);
btn.addActionListener(this);
btn.addKeyListener(this);
btn=new Button(“9“);
panel.add(btn);
btn.addActionListener(this);
btn.addKeyListener(this);
btn=new Button(“*“);
panel.add(btn);
btn.addActionListener(this);
btn.addKeyListener(this);
btn=new Button(“0“);
panel.add(btn);
btn.addActionListener(this);
btn.addKeyListener(this);
btn=new Button(“.“);
panel.add(btn);
btn.addActionListener(this);
btn.addKeyListener(this);
btn=new Button(“/“);
panel.add(btn);
btn.addActionListener(this);
btn.addKeyListener(this);
btn=new Button(“=“);
panel.add(btn);
btn.addActionListener(this);
btn.addKeyListener(this);
this.add(panel,BorderLayout.CENTER);
}
/**
* @param args
*/
public static void main(String args) {
// TODO Auto-generated method stub
Caculator mainframe=new Caculator();
mainframe.setTitle(“testing Caculator“);
mainframe.setSize(400,400);
mainframe.setVisible(true);

}
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
if(e.getActionCommand()==“+“){
x= Float.parseFloat(tf.getText());
code=0;
this.tf.setText(““);

}
if(e.getActionCommand()==“-“){
x= Float.parseFloat(tf.getText());
code=1;
this.tf.setText(““);

}
if(e.getActionCommand()==“*“){
x= Float.parseFloat(tf.getText());
code=2;
this.tf.setText(““);

}
if(e.getActionCommand()==“/“){
x= Float.parseFloat(tf.getText());
code=3;
this.tf.setText(““);

}

if(e.getActionCommand()!=“+“&&e.getActionCommand()!=“-“&&e.getActionCommand()!=“*“&&e.getActionCommand()!=“/“&&e.getActionCommand()!=“=“){
if(enable){
if(first){
System.out.println(“haha“);
tf.setText(e.getActionCommand());
first=false;
}
else {
tf.setText(tf.getText()+e.getActionCommand());
}

}

else {
tf.setText(e.getActionCommand());
enable=true;

}
}
if(e.getActionCommand()==“=“){
switch(code){
case 0:
y=x+Float.parseFloat(this.tf.getText());
tf.setText(Float.toString(y));
enable=false;
break;
case 1:
y=x-Float.parseFloat(this.tf.getText());
tf.setText(Float.toString(y));
enable=false;
break;
case 2:
y=x*Float.parseFloat(this.tf.getText());
tf.setText(Float.toString(y));
enable=false;
break;
case 3:
y=x/Float.parseFloat(this.tf.getText());
tf.setText(Float.toString(y));
enable=false;
break;
}

}

}
public void keyPressed(KeyEvent e) {
// TODO Auto-generated method stub
if(e.getKeyChar()==’+’){
x= Float.parseFloat(tf.getText());
code=0;
this.tf.setText(““);

}
if(e.getKeyChar()==’-’){
x= Float.parseFloat(tf.getText());
code=1;
this.tf.setText(““);

}
if(e.getKeyChar()==’*’){
x= Float.parseFloat(tf.getText());
code=2;
this.tf.setText(““);

}
if(e.getKeyChar()==’/’){
x= Float.parseFloat(tf.getText());
code=3;
this.tf.setText(““);

}

if(e.getKeyChar()==’1’||e.getKeyChar()==’2’||e.getKeyChar()==’3’||e.getKeyChar()==’0’
||e.getKeyChar()==’4’||e.getKeyChar()==’5’||e.getKeyChar()==’6’||e.getKeyChar()==’.’
||e.getKeyChar()==’7’||e.getKeyChar()==’8’||e.getKeyChar()==’9’){
System.out.println(“hai“);
if(enable){
if(first){
System.out.println(“hehe“);
str=Character.toString(e.getKeyChar());
tf.setText(str);
first=false;
}
else {

str=Character.toString(e.getKeyChar());
tf.setText(tf.getText()+str);
}

}

else {

str=Character.toString(e.getKeyChar());
tf.setText(str);
enable=true;

}
}
if(e.getKeyCode()==KeyEvent.VK_ENTER){
switch(code){
case 0:
y=x+Float.parseFloat(this.tf.getText());
tf.setText(Float.toString(y));
enable=false;
break;
case 1:
y=x-Float.parseFloat(this.tf.getText());
tf.setText(Float.toString(y));
enable=false;
break;
case 2:
y=x*Float.parseFloat(this.tf.getText());
tf.setText(Float.toString(y));
enable=false;
break;
case 3:
y=x/Float.parseFloat(this.tf.getText());
tf.setText(Float.toString(y));
enable=false;
break;
}

}
}
public void keyReleased(KeyEvent arg0) {
// TODO Auto-generated method stub

}
public void keyTyped(KeyEvent arg0) {
// TODO Auto-generated method stub

}

}
-启动