package NET.worlds.console; import NET.worlds.core.RegKey; import NET.worlds.core.RegKeyNotFoundException; import java.io.IOException; public class IClassFactory extends IUnknown { private static final String IID_IClassFactory = "{00000001-0000-0000-C000-000000000046}"; private long _registerID; public IClassFactory() throws IOException { } public IClassFactory(String svrID) throws IOException { super(svrID, "{00000001-0000-0000-C000-000000000046}"); } public IClassFactory(IUnknown pIUnknown) throws IOException, OLEInvalidObjectException { super(pIUnknown, "{00000001-0000-0000-C000-000000000046}"); } public synchronized void activate(String CLSID) throws IOException { assert this._registerID == 0L; assert Main.isMainThread(); if ((ActiveX.getDebugLevel() & 8) > 0) { System.out.println(this + ": activating server as " + CLSID); } this._registerID = this.nActivate(CLSID); if ((ActiveX.getDebugLevel() & 8) > 0) { System.out.println(this + ": successful"); } } public synchronized void deactivate() throws IOException { assert this._registerID != 0L; assert Main.isMainThread(); if ((ActiveX.getDebugLevel() & 8) > 0) { System.out.println(this + ": deactivating server"); } this.nDeactivate(this._registerID); } @Override public synchronized void Release() throws OLEInvalidObjectException { if (this._refs == 1 && this._registerID != 0L) { if ((ActiveX.getDebugLevel() & 4) > 0) { System.out.println(this + ": deactivating before Release"); } try { this.deactivate(); } catch (IOException var2) { System.out.println("DEBUG: " + this); var2.printStackTrace(System.out); assert false; } this._registerID = 0L; } super.Release(); } @Override public String internalData() { return "_registerID = " + this._registerID + ", " + super.internalData(); } @Override public String toString() { return "IClassFactory(" + this.internalData() + ")"; } public void register(String friendlyName, String CLSID, String VerIndProgID, String ProgID) { try { RegKey root = RegKey.getRootKey(0); RegKey gammaKey = new RegKey(root, "world\\shell\\open\\command", 0); String gammaPath = gammaKey.getStringValue(""); int argIndx = gammaPath.indexOf(" \"%1\""); gammaPath = gammaPath.substring(0, argIndx); RegKey classKey = new RegKey(root, "CLSID\\" + CLSID, 2); classKey.setStringValue("", friendlyName, false); RegKey subKey = new RegKey(classKey, "LocalServer32", 2); subKey.setStringValue("", gammaPath, false); subKey.close(); subKey = new RegKey(classKey, "ProgID", 2); subKey.setStringValue("", ProgID, false); subKey.close(); subKey = new RegKey(classKey, "VersionIndependentProgID", 2); subKey.setStringValue("", VerIndProgID, false); subKey.close(); classKey.close(); RegKey verIndKey = new RegKey(root, VerIndProgID, 2); verIndKey.setStringValue("", friendlyName, false); subKey = new RegKey(verIndKey, "CLSID", 2); subKey.setStringValue("", CLSID, false); subKey.close(); subKey = new RegKey(verIndKey, "CurVer", 2); subKey.setStringValue("", ProgID, false); subKey.close(); verIndKey.close(); RegKey progKey = new RegKey(root, ProgID, 2); progKey.setStringValue("", friendlyName, false); subKey = new RegKey(progKey, "CLSID", 2); subKey.setStringValue("", CLSID, false); subKey.close(); progKey.close(); } catch (RegKeyNotFoundException var13) { System.out.println("Warning: System Registry not configured properly by Worlds."); } } private native long nActivate(String var1) throws IOException; private native void nDeactivate(long var1) throws IOException; }