/* class JactiveXApp demonstrates using ActiveX automation objects from Java applet for IE JVM M. Gallant 08/07/2002 */ import java.awt.*; import java.awt.event.*; import java.applet.*; import java.io.* ; import java.util.*; import com.ms.security.*; import com.ms.wfc.app.*; import com.ms.win32.SHELLEXECUTEINFO; import com.ms.win32.win; import com.ms.activeX.*; import com.ms.com.*; public class JactiveXApp extends Applet implements ActionListener { TextArea ta = new TextArea (25, 80); TextField tf = new TextField(" Enter File Path Here ") ; private Button activex = new Button("Show File Properties (ActiveX control)") ; private Button shellexe = new Button("Show File Properties (ShellExecuteExe)") ; public void init() { add(new Label("File Path:", Label.RIGHT)); add(tf); Panel pf = new Panel(); pf.setLayout(new GridLayout(2,1,5,5)) ; pf.add(activex); activex.setBackground(Color.red) ; activex.addActionListener(this); pf.add(shellexe); shellexe.setBackground(Color.red) ; shellexe.addActionListener(this); add(pf) ; } public void actionPerformed(ActionEvent e) { if( e.getSource() == activex) shellFileproperties1(tf.getText()) ; else if(e.getSource() == shellexe) shellFileproperties2(tf.getText()) ; } private final boolean shellFileproperties1(String filename) { Variant namespace, folder; Variant [] methodargs = new Variant[1]; try { ActiveXControl oShellApp = new ActiveXControl("shell.application"); methodargs[0] = new Variant(0); namespace = oShellApp.invoke("NameSpace", methodargs); //System.out.println("Type namespace: " + namespace.getvt()) ; folder = Dispatch.call(namespace, "ParseName", filename) ; //System.out.println("Type folder: " + folder.getvt()) ; Dispatch.call(folder, "InvokeVerb", "P&roperties") ; return true ; } catch(Exception exc){ System.out.println(exc) ; return false ; } } private final boolean shellFileproperties2(String filename) { SHELLEXECUTEINFO shex = new SHELLEXECUTEINFO(); shex.fMask = win.SEE_MASK_INVOKEIDLIST | win.SEE_MASK_FLAG_NO_UI ; shex.lpVerb = "properties"; shex.lpFile = filename; shex.nShow = 0; boolean fresult = ShellExecuteEx(shex); if(!fresult) System.out.println("ShellExecuteEx failed") ; return fresult ; } public void paint(Graphics g) { g.setColor(Color.black) ; g.drawRect(0,0,this.getSize().width-1, this.getSize().height-1) ; } /** @dll.import("SHELL32",auto) */ private native static boolean ShellExecuteEx(SHELLEXECUTEINFO pshex); }