0

protocolhandler から 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();
        }
    }
4

1 に答える 1

0

最終プロセス process = Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler "+fileName);

于 2012-08-23T17:21:11.253 に答える