使用命令行参数启动Solidworks EDrawingsViewer

时间:2012-02-16 15:47:32

标签: java solidworks

我有一个简单的类,它使用来自protocolhandler的edrawingsviewer应用程序打开文件。如何在点击后强制程序终止?

这就是我所拥有的,我认为它不起作用的原因是因为运行时环境用于启动它。除非进行运行时环境调用,否则在通过命令行启动时,它似乎不会将文件名作为参数拾取。

如何使用文件名启动edrawingsviewer而不使用对rundll32的调用?

    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();
        }
    }

1 个答案:

答案 0 :(得分:0)

final Process process = Runtime.getRuntime()。exec(“rundll32 url.dll,FileProtocolHandler”+ fileName);

相关问题