比如我想在程序中打开控制面板界面,
需要运行:rundll32.exe shell32.dll,Control_RunDLL
在vc中可以使用Winexec("rundll32.exe shell32.dll,Control_RunDLL",1),
在java中怎么实现呢?

解决方案 »

  1.   

    public class Demo{
       public static void main(String args[]){
          Runtime rn=Runtime.getRuntime();
             Process p=null;
          try{
                p=rn.exec("\"D:/AnyQ/AnyQ.exe\"");
         }catch(Exception e){
            System.out.println("Error exec AnyQ");
         }
       }
    }
      

  2.   

    public class Demo{
    调用系统记事本
       public static void main(String args[]){
          Runtime rn=Runtime.getRuntime();
             Process p=null;
          try{
                p=rn.exec("notepad");
         }catch(Exception e){
            System.out.println("Error exec notepad");
         }
       }
    }
      

  3.   

    看看Runtime 类API吧,如果参数多得时候,最好用数组做exec得参数
      

  4.   

    谢谢楼上,基本解决但是很奇怪,我运行“rundll32.exe rnaui.dll,RnaDial 163”
    竟然报:
    ---------------------------
    RUNDLL
    ---------------------------
    加载 rnaui.dll 时出错找不到指定的模块。
    ---------------------------
    确定   
    ---------------------------163是我建立的一个拨号连接,我想实现调用拨号的功能,不知道怎么做好?
      

  5.   

    解决了java中拨号的问题,我会继续适当加分的 :)