使用命令行参数启动Solidworks EDrawingsViewer

问题描述:

我有一个简单的类,它使用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(); 
     } 
    } 

最终工艺过程=调用Runtime.getRuntime()EXEC( “RUNDLL32 URL.DLL,FileProtocolHandler” +文件名)。