0
我有一個簡單的類,它使用protocolhandler中的edrawingsviewer應用程序打開文件。如何強制程序在點擊後終止?使用命令行參數啓動Solidworks 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();
}
}