06:32 XPCOM OS のシステム情報を得る

Class
@mozilla.org/system-info;1
Interface
nsIPropertyBag2
const Cc = Components.classes;
const Ci = Components.interfaces;
var sysInfo = Cc['@mozilla.org/system-info;1'].getService(Ci.nsIPropertyBag2);
var pratform = sysInfo.getProperty('name');

Properties and Example

  • name
    • Windows_NT
    • Mac OS X
    • Linux
  • version
    • 5.1
  • arch
    • x86
  • host
    • femo

06:01 XPCOM OS の環境変数を得る/設定する

Class
@mozilla.org/process/environment;1
Interface
nsIEnvironment
const Cc = Components.classes;
const Ci = Components.interfaces;
var env = Cc['@mozilla.org/process/environment;1'].getService(Ci.nsIEnvironment);
var path = env.get('path');

Method

Boolean exists (String aName)
Check the existence of an environment variable.
環境変数が存在するかどうか判定する
String get (String aName)
returns the value of the env varible. An empty string will be returned when hte env variable dose not exist or when the value itself is an empty string - please use exists() to probe whether the env variable exists or not.
環境変数の値を返す。環境変数が存在しない、または、空文字列の場合、空文字列が返る。exists()メソッドを使って事前に判定してください。
String set (String aName, String aValue)
Set the value of an environment variable.
環境変数を設定する