Get Thunderbird version

Table of contents
No headers

On Thunderbird version 3.0b3pre and later, you can use the following snippet to get the Thunderbird version. (Version 3.0b3pre was the first build to include STEEL.)

var versionChecker = 
Components.classes["@mozilla.org/xpcom/version-comparator;1"].getService(Components.interfaces.nsIVersionComparator);

if (versionChecker.compare(Application.version, "3.0b4") >= 0)
  // code for >= 3.0b4
else
  // code for <  3.0b4

For versions prior to 3.0b3pre, you can use something like this:

var version;
if ( "@mozilla.org/xre/app-info;1" in Components.classes )
  version = Components.classes["@mozilla.org/xre/app-info;
1"].getService(Components.interfaces.nsIXULAppInfo).version;
else
  version = Components.classes["@mozilla.org/preferences-service;
1"].getService(Components.interfaces.nsIPrefBranch).getCharPref
("app.version");

var versionChecker = Components.classes["@mozilla.org/xpcom/version-
comparator;1"].getService(Components.interfaces.nsIVersionComparator);

if ( versionChecker.compare( version, "3.0b3" ) >= 0 )
  // code for >= 3.0b3
else
  // code for < 3.0b3

Tags (1)

Edit tags

Attachments (0)

 

Attach file