我有一个简单的类,使用协议处理程序中的edrawingsviewer应用程序打开一个文件。如何在单击“上一步”时强制程序终止?
这就是我所拥有的,我认为它不工作的原因是因为运行时环境是用来启动它的。在通过命令行启动它时,它似乎不会将文件名作为参数,除非进行了运行时环境调用。
如何在不调用rundll32的情况下使用文件名启动edrawingsviewer?
private void initBackButton() {
backButton = new JButton("BACK");
backButton.setPreferredSize(BUTTONSIZE);
backButton.setMinimumSize(BUTTONSIZE);
backButton.setSize(BUTTONSIZE);
backButton.setMaximumSize(BUTTONSIZE);
backButton.setAlignmentX(0.0F);
backButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.out.println("checking for open processes");
for (Process p : processList) {
if (p != null) {
p.destroy();
System.out.println("killing process");
}
}
setValue(backButton);
}
});
}
private void addButtonToPanel(final File file) {
final JButton button = new JButton();
button.setPreferredSize(BUTTONSIZE);
button.setSize(BUTTONSIZE);
button.setMinimumSize(BUTTONSIZE);
button.setMaximumSize(BUTTONSIZE);
button.setFont(FONT);
button.setText(file.getName().split(jobString)[1]);
button.setHorizontalTextPosition(SwingConstants.LEFT);
button.setHorizontalAlignment(SwingConstants.LEFT);
final List<Process> pl = this.processList;
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
EDrawingDialog.openEDrawingForFileName(file.getName(), button, pl);
} catch (Exception ex) {
System.out.println("addButtonToPane()"+ex);
}
}
});
buttonPanel.add(button);
}
public static void openEDrawingForFileName(String fileName, JButton b, List<Process> processList) {
try {
final Process process = Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler \\\\xxx.xxx.x.xx\\www\\HMI\\POD EDRAWINGS\\" + fileName);
processList.add(process);
} catch (IOException e) {
e.printStackTrace();
}
}发布于 2012-08-24 01:21:11
最终进程进程= Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler“+文件名);
https://stackoverflow.com/questions/9314346
复制相似问题