Your Search Results


    This feature is obsolete. Although it may still work in some browsers, its use is discouraged since it could be removed at any time. Try to avoid using it.

    nsIRegistry on MXR

    Other documentation: libreg source, reg.h in particular



    It works like this.

    var Cc = Components.classes;
    var Ci = Components.interfaces;
    var rc = Cc[";1"];
    var rs = rc.getService(Ci.nsIRegistry);

    Now you have the registry service.

    rs.openWellKnownRegistry(2);  // 2 signifies the ApplicationRegistry, if I understand right
    var st = rs.enumerateAllSubtrees(2);  // 2 signifies "common", see libreg source (reg.h) for info

    Now you have an nsIEnumerator that can report the subtrees.

    try {
      do {
        var data = st.currentItem();
        if( data instanceof Ci.nsIRegistryNode )
          print("nsIRegistryNode: " + data.nameUTF8 + " (" + data.key + ")");;
      } while( Components.lastResult == 0 );
    } catch(e) {}

    Now, the output is something like:

    Profiles (344)
    Profiles/default (530)
    Profiles/foo (1046)
    Profiles/bar (1518)

    The number inside the parenthesis is the "key." You can use this key with the rest of the nsIRegistry API (see MXR).

    Now, I know from visual inspection that there's a key called "directory" for each profile. I don't know how to get the other keys' names automatically, but I do know how to look up the directory for a particular profile.

    js> rs.getStringUTF8(530, "directory")  // 530: key corresponding with Profiles/default

    The output is something like:



    Can we change it?

    js> rs.setStringUTF8(530, "directory", "/home/lion/somewhere/else")
    js> rs.getStringUTF8(530, "directory")


    Now, the only puzzle is: how do you save it?

    js> rs.flush()  // this is not enough...

    Perhaps if we quit with the XPConnect:appShellService, it will work.

    Document Tags and Contributors

    Contributors to this page: groovecoder, Sheppy, Nickolay, PWeilbacher, LionKimbro
    Last updated by: Sheppy,