【问题标题】:Get defaultGroupId of firefox.exe in Win7Win7获取firefox.exe的defaultGroupId
【发布时间】:2014-06-08 02:39:51
【问题描述】:

我试图在 Win7 中将每个配置文件的窗口组分开。我发现这是可行的,方法是在taskbar.grouping.useprofile 的所有配置文件中创建首选项并将其设置为 true 并重新启动所有配置文件 (https://bugzilla.mozilla.org/show_bug.cgi?id=644914) 的浏览器。

但它的工作原理是它改变了 defaultGroupId Cc["@mozilla.org/windows-taskbar;1"].getService(Ci.nsIWinTaskbar).defaultGroupId

问题在于,在创建此首选项之前,Firefox 使用 firefox.exe 的 defaultGroupId,但在创建首选项配置文件后,现在的 defaultGroupId 与此不同。因此,如果最初,在创建该首选项并重新启动浏览器之前,如果用户已固定firefox.exe,那么在创建首选项并重新启动浏览器后它将始终是分开的。

所以我想做的是在profiles.ini中标记为Default=1的配置文件我想以编程方式使其使用firefox.exedefaultGroupId,但事情是一旦创建了pref并重新启动了浏览器我无法弄清楚firefox.exedefaultGroupId

我最后的解决方案是:(1)安装我的插件时,如果taskbar.grouping.useprofile 的首选项在那里并设置为true,然后将其设置为false并要求用户重新启动重新启动它将找出defaultGrupId并将其存储为首选项然后我将添加首选项然后要求用户再次重新启动(真的不想这样做)(2)如果@的首选项安装我的插件987654334@ 在那里并设置为 true 然后将首选项设置为当前 defaultGroupId 的值。

【问题讨论】:

标签: windows-7 process firefox-addon profile xpcom


【解决方案1】:

感谢@Neil 让我知道可以在注册表中找到默认组 ID,即使在将 taskbar.grouping.useprofile 的首选项设置为 true 之后也是如此。

ask.m.o :: How to calculate default group id (Win7+)

来自 ask.m.o 的解决方案:

感谢@Neil,我通过这种方式获得了价值。我运行的唯一可能的问题 into, 如果在 TaskBarIDs 下有多个值, 是什么 这可能吗?

如果值类型是0,我也可能会遇到问题 TYPE_NONEREG_NONE 是否可以读取这些值?

var wrk = Cc['@mozilla.org/windows-registry-key;1'].createInstance(Components.interfaces.nsIWindowsRegKey);
var keypath = 'Software\\Mozilla\\' + Services.appinfo.name + '\\TaskBarIDs'; //Services.appinfo.name == appInfo->GetName(appName) // http://mxr.mozilla.org/comm-central/source/mozilla/widget/windows/WinTaskbar.cpp#284
try {
  wrk.open(wrk.ROOT_KEY_LOCAL_MACHINE, keypath, wrk.ACCESS_READ);
} catch(ex) {
  //console.warn(ex)
  if (ex.message != 'Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIWindowsRegKey.open]') {
    throw ex;
  } else {
    try {
      wrk.open(wrk.ROOT_KEY_CURRENT_USER, keypath, wrk.ACCESS_READ);
    } catch (ex) {
      throw ex;
    }
  }
}
//list children
var numVals = wrk.valueCount;
for (var i=0; i<numVals; i++) {
  var keyval = {
    Name: wrk.getValueName(i)
  };
  keyval.Type = wrk.getValueType(keyval.Name);
  keyval.TypeStr = win_RegTypeStr_from_RegTypeInt(keyval.Type);
  if (keyval.Type == 0) {
    throw new Error('keyval.Type is `0` I have no idea how to read this value keyval.Type == `' + keyval.Type + '` and keyval. Name == `' + keyval.Name + '`');    
  }
  keyval.Value = wrk['read' + keyval.TypeStr + 'Value'](keyval.Name)
  console.log('keyval:', uneval(keyval), keyval);
}
wrk.close();
function win_RegTypeStr_from_RegTypeInt(int) {
  if (int == 1) {
    return 'String';
  } else if (int == 3) {
    return 'Binary';
  } else if (int == 4) {
    return 'Int';
  } else if (int == 11) {
    return 'Int64';
  } else if (int == 0) {
    return 'NONE';
  } else {
    throw new Error('keyval.Type is not any of the expected values of 0, 2, 3, 4, or 11 so am now confused. keyval.Type == `' + int + '`');
  }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-01-20
    • 1970-01-01
    • 2017-09-17
    • 2013-02-05
    • 2013-07-01
    • 1970-01-01
    相关资源
    最近更新 更多