第1个回答 2013-09-21
用这个代码试一下!希望能帮助到你
import java.awt.*;
import java.io.*;
import java.awt.event.*;
import javax.swing.*;
public class Test
{ public Test()
{ JFrame f=new JFrame("TEST");
Container c=f.getContentPane();
c.setLayout(new FlowLayout());
JButton b=new JButton("帮助");
b.addActionListener(new ActionListener()
{ public void actionPerformed(ActionEvent e)
{ try
{ String cmd="rundll32 url.dll FileProtocolHandler file://D:/1000/help.txt ";//启动相应的windows程序来打开文件
Process p = Runtime.getRuntime().exec(cmd);
}
catch (Exception e1)
{ System.out.println(e1);
}
}
});
c.add(b);
f.setBounds(100,100,300,300);
f.setVisible(true);
}
public static void main(String arg[])
{ new Test();
}
}
//Rundll32.exe DLLname,Functionname [Arguments] ,DLLname为需要执行的DLL文件名;
//Functionname为前边需要执行的DLL文件的具体引出函数;[Arguments]为引出函数的具体参数