/* Java applet for Win32 using WFC classes; Accesses HKCR\CLSID\ GUID subkeys and enumerates all keys with existing subkeys ProgID and saves default values for ProgID and InProcServer32 to user specified file. M. Gallant 02/03/2001 */ import com.ms.wfc.app.Registry; import com.ms.wfc.app.RegistryKey; import com.ms.security.*; import java.awt.*; import java.awt.event.*; import java.applet.*; import java.io.* ; import java.util.*; public final class ProgIDApplet extends Applet implements ActionListener { FontMetrics fm; private TextArea ta = new TextArea (35, 40); private Button startbutton = new Button("Get ProgID Values") ; private Button savebutton = new Button("Save ProgID Values") ; private Button clearbutton = new Button("Clear") ; private boolean gotprogids = false; private String progids = ""; public void init() { try { if (Class.forName("com.ms.security.PolicyEngine") != null) { // required for IE PolicyEngine.assertPermission(PermissionID.SYSTEM); } } catch (Throwable cnfe) { } this.setBackground(Color.white) ; this.setLayout(new BorderLayout()) ; Panel p1 = new Panel() ; startbutton.addActionListener(this) ; p1.add(startbutton) ; startbutton.setBackground(Color.green) ; savebutton.addActionListener(this) ; p1.add(savebutton) ; savebutton.setBackground(Color.red) ; clearbutton.addActionListener(this) ; p1.add(clearbutton) ; clearbutton.setBackground(Color.gray) ; this.add(p1, "North") ; this.add(ta, "Center") ; } public void actionPerformed(ActionEvent e) { if( (e.getActionCommand()).equals("Clear")) { ta.setText("") ; gotprogids = false; progids="" ; } else if( (e.getActionCommand()).equals("Get ProgID Values")) { progids = getProgids() ; // System.out.println("Results: \n" + progids) ; ta.setText("") ; ta.append(progids) ; } else if( (e.getActionCommand()).equals("Save ProgID Values")) { if(gotprogids) saveProgids() ; else ta.append("Haven't got ProgIDs yet!") ; } } private final void saveProgids() { BufferedWriter buffout = null; FileDialog dialog = new FileDialog(new Frame(), "Save File", FileDialog.SAVE); dialog.setFile("_ProgIDvalues.txt"); dialog.show(); String sdirectory = dialog.getDirectory() ; String sfile = dialog.getFile(); if(sdirectory == null || sfile == null) return ; // do nothing if user cancels dialog. String outfile = sdirectory + sfile ; // build file path. try{ buffout = new BufferedWriter(new FileWriter(outfile)) ; buffout.write(progids) ; buffout.close() ; } catch(IOException ieo) { } finally { try { if (buffout != null) buffout.close(); } catch (IOException e) {} } } private final String getProgids() { int guidcount = 0; // number of GUID subkey values in HKCR\CLSID subkey. String subkeypath = "CLSID"; RegistryKey certroot = Registry.CLASSES_ROOT.getSubKey(subkeypath, true) ; // read only for safety RegistryKey guidsubkey = null; if(certroot==null){ return("No HKCR\\CLSID Key"); } if((guidcount=certroot.getSubKeyCount())==0){ return("No GUID values in HKCR\\CLSID Key"); } StringBuffer strbuff = new StringBuffer("----- HKCR\\CLSID\\[guid] keys with ProgID Subkeys ------ \r\n"); strbuff.append("" + new Date() + "\r\n\r\n") ; String[] guidkeys = certroot.getSubKeyNames() ; for(int j=0; j