michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* vim:set ts=2 sw=2 sts=2 et cindent: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "nsISupports.idl" michael@0: michael@0: native HKEY(HKEY); michael@0: michael@0: /** michael@0: * This interface is designed to provide scriptable access to the Windows michael@0: * registry system ("With Great Power Comes Great Responsibility"). The michael@0: * interface represents a single key in the registry. michael@0: * michael@0: * This interface is highly Win32 specific. michael@0: */ michael@0: [scriptable, uuid(2555b930-d64f-437e-9be7-0a2cb252c1f4)] michael@0: interface nsIWindowsRegKey : nsISupports michael@0: { michael@0: /** michael@0: * Root keys. The values for these keys correspond to the values from michael@0: * WinReg.h in the MS Platform SDK. The ROOT_KEY_ prefix corresponds to the michael@0: * HKEY_ prefix in the MS Platform SDK. michael@0: * michael@0: * This interface is not restricted to using only these root keys. michael@0: */ michael@0: const unsigned long ROOT_KEY_CLASSES_ROOT = 0x80000000; michael@0: const unsigned long ROOT_KEY_CURRENT_USER = 0x80000001; michael@0: const unsigned long ROOT_KEY_LOCAL_MACHINE = 0x80000002; michael@0: michael@0: /** michael@0: * Values for the mode parameter passed to the open and create methods. michael@0: * The values defined here correspond to the REGSAM values defined in michael@0: * WinNT.h in the MS Platform SDK, where ACCESS_ is replaced with KEY_. michael@0: * michael@0: * This interface is not restricted to using only these access types. michael@0: */ michael@0: const unsigned long ACCESS_BASIC = 0x00020000; michael@0: const unsigned long ACCESS_QUERY_VALUE = 0x00000001; michael@0: const unsigned long ACCESS_SET_VALUE = 0x00000002; michael@0: const unsigned long ACCESS_CREATE_SUB_KEY = 0x00000004; michael@0: const unsigned long ACCESS_ENUMERATE_SUB_KEYS = 0x00000008; michael@0: const unsigned long ACCESS_NOTIFY = 0x00000010; michael@0: const unsigned long ACCESS_READ = ACCESS_BASIC | michael@0: ACCESS_QUERY_VALUE | michael@0: ACCESS_ENUMERATE_SUB_KEYS | michael@0: ACCESS_NOTIFY; michael@0: const unsigned long ACCESS_WRITE = ACCESS_BASIC | michael@0: ACCESS_SET_VALUE | michael@0: ACCESS_CREATE_SUB_KEY; michael@0: const unsigned long ACCESS_ALL = ACCESS_READ | michael@0: ACCESS_WRITE; michael@0: const unsigned long WOW64_32 = 0x00000200; michael@0: const unsigned long WOW64_64 = 0x00000100; michael@0: michael@0: michael@0: /** michael@0: * Values for the type of a registry value. The numeric values of these michael@0: * constants are taken directly from WinNT.h in the MS Platform SDK. michael@0: * The Microsoft documentation should be consulted for the exact meaning of michael@0: * these value types. michael@0: * michael@0: * This interface is somewhat restricted to using only these value types. michael@0: * There is no method that is directly equivalent to RegQueryValueEx or michael@0: * RegSetValueEx. In particular, this interface does not support the michael@0: * REG_MULTI_SZ and REG_EXPAND_SZ value types. It is still possible to michael@0: * enumerate values that have other types (i.e., getValueType may return a michael@0: * type not defined below). michael@0: */ michael@0: const unsigned long TYPE_NONE = 0; // REG_NONE michael@0: const unsigned long TYPE_STRING = 1; // REG_SZ michael@0: const unsigned long TYPE_BINARY = 3; // REG_BINARY michael@0: const unsigned long TYPE_INT = 4; // REG_DWORD michael@0: const unsigned long TYPE_INT64 = 11; // REG_QWORD michael@0: michael@0: /** michael@0: * This attribute exposes the native HKEY and is available to provide C++ michael@0: * consumers with the flexibility of making other Windows registry API calls michael@0: * that are not exposed via this interface. michael@0: * michael@0: * It is possible to initialize this object by setting an HKEY on it. In michael@0: * that case, it is the responsibility of the consumer setting the HKEY to michael@0: * ensure that it is a valid HKEY. michael@0: * michael@0: * WARNING: Setting the key does not close the old key. michael@0: */ michael@0: [noscript] attribute HKEY key; michael@0: michael@0: /** michael@0: * This method closes the key. If the key is already closed, then this michael@0: * method does nothing. michael@0: */ michael@0: void close(); michael@0: michael@0: /** michael@0: * This method opens an existing key. This method fails if the key michael@0: * does not exist. michael@0: * michael@0: * NOTE: On 32-bit Windows, it is valid to pass any HKEY as the rootKey michael@0: * parameter of this function. However, for compatibility with 64-bit michael@0: * Windows, that usage should probably be avoided in favor of openChild. michael@0: * michael@0: * @param rootKey michael@0: * A root key defined above or any valid HKEY on 32-bit Windows. michael@0: * @param relPath michael@0: * A relative path from the given root key. michael@0: * @param mode michael@0: * Access mode, which is a bit-wise OR of the ACCESS_ values defined michael@0: * above. michael@0: */ michael@0: void open(in unsigned long rootKey, in AString relPath, in unsigned long mode); michael@0: michael@0: /** michael@0: * This method opens an existing key or creates a new key. michael@0: * michael@0: * NOTE: On 32-bit Windows, it is valid to pass any HKEY as the rootKey michael@0: * parameter of this function. However, for compatibility with 64-bit michael@0: * Windows, that usage should probably be avoided in favor of createChild. michael@0: * michael@0: * @param rootKey michael@0: * A root key defined above or any valid HKEY on 32-bit Windows. michael@0: * @param relPath michael@0: * A relative path from the given root key. michael@0: * @param mode michael@0: * Access mode, which is a bit-wise OR of the ACCESS_ values defined michael@0: * above. michael@0: */ michael@0: void create(in unsigned long rootKey, in AString relPath, in unsigned long mode); michael@0: michael@0: /** michael@0: * This method opens a subkey relative to this key. This method fails if the michael@0: * key does not exist. michael@0: * michael@0: * @return nsIWindowsRegKey for the newly opened subkey. michael@0: */ michael@0: nsIWindowsRegKey openChild(in AString relPath, in unsigned long mode); michael@0: michael@0: /** michael@0: * This method opens or creates a subkey relative to this key. michael@0: * michael@0: * @return nsIWindowsRegKey for the newly opened or created subkey. michael@0: */ michael@0: nsIWindowsRegKey createChild(in AString relPath, in unsigned long mode); michael@0: michael@0: /** michael@0: * This attribute returns the number of child keys. michael@0: */ michael@0: readonly attribute unsigned long childCount; michael@0: michael@0: /** michael@0: * This method returns the name of the n'th child key. michael@0: * michael@0: * @param index michael@0: * The index of the requested child key. michael@0: */ michael@0: AString getChildName(in unsigned long index); michael@0: michael@0: /** michael@0: * This method checks to see if the key has a child by the given name. michael@0: * michael@0: * @param name michael@0: * The name of the requested child key. michael@0: */ michael@0: boolean hasChild(in AString name); michael@0: michael@0: /** michael@0: * This attribute returns the number of values under this key. michael@0: */ michael@0: readonly attribute unsigned long valueCount; michael@0: michael@0: /** michael@0: * This method returns the name of the n'th value under this key. michael@0: * michael@0: * @param index michael@0: * The index of the requested value. michael@0: */ michael@0: AString getValueName(in unsigned long index); michael@0: michael@0: /** michael@0: * This method checks to see if the key has a value by the given name. michael@0: * michael@0: * @param name michael@0: * The name of the requested value. michael@0: */ michael@0: boolean hasValue(in AString name); michael@0: michael@0: /** michael@0: * This method removes a child key and all of its values. This method will michael@0: * fail if the key has any children of its own. michael@0: * michael@0: * @param relPath michael@0: * The relative path from this key to the key to be removed. michael@0: */ michael@0: void removeChild(in AString relPath); michael@0: michael@0: /** michael@0: * This method removes the value with the given name. michael@0: * michael@0: * @param name michael@0: * The name of the value to be removed. michael@0: */ michael@0: void removeValue(in AString name); michael@0: michael@0: /** michael@0: * This method returns the type of the value with the given name. The return michael@0: * value is one of the "TYPE_" constants defined above. michael@0: * michael@0: * @param name michael@0: * The name of the value to query. michael@0: */ michael@0: unsigned long getValueType(in AString name); michael@0: michael@0: /** michael@0: * This method reads the string contents of the named value as a Unicode michael@0: * string. michael@0: * michael@0: * @param name michael@0: * The name of the value to query. This parameter can be the empty michael@0: * string to request the key's default value. michael@0: */ michael@0: AString readStringValue(in AString name); michael@0: michael@0: /** michael@0: * This method reads the integer contents of the named value. michael@0: * michael@0: * @param name michael@0: * The name of the value to query. michael@0: */ michael@0: unsigned long readIntValue(in AString name); michael@0: michael@0: /** michael@0: * This method reads the 64-bit integer contents of the named value. michael@0: * michael@0: * @param name michael@0: * The name of the value to query. michael@0: */ michael@0: unsigned long long readInt64Value(in AString name); michael@0: michael@0: /** michael@0: * This method reads the binary contents of the named value under this key. michael@0: * michael@0: * JavaScript callers should take care with the result of this method since michael@0: * it will be byte-expanded to form a JS string. (The binary data will be michael@0: * treated as an ISO-Latin-1 character string, which it is not). michael@0: * michael@0: * @param name michael@0: * The name of the value to query. michael@0: */ michael@0: ACString readBinaryValue(in AString name); michael@0: michael@0: /** michael@0: * This method writes the unicode string contents of the named value. The michael@0: * value will be created if it does not already exist. michael@0: * michael@0: * @param name michael@0: * The name of the value to modify. This parameter can be the empty michael@0: * string to modify the key's default value. michael@0: * @param data michael@0: * The data for the value to modify. michael@0: */ michael@0: void writeStringValue(in AString name, in AString data); michael@0: michael@0: /** michael@0: * This method writes the integer contents of the named value. The value michael@0: * will be created if it does not already exist. michael@0: * michael@0: * @param name michael@0: * The name of the value to modify. michael@0: * @param data michael@0: * The data for the value to modify. michael@0: */ michael@0: void writeIntValue(in AString name, in unsigned long data); michael@0: michael@0: /** michael@0: * This method writes the 64-bit integer contents of the named value. The michael@0: * value will be created if it does not already exist. michael@0: * michael@0: * @param name michael@0: * The name of the value to modify. michael@0: * @param data michael@0: * The data for the value to modify. michael@0: */ michael@0: void writeInt64Value(in AString name, in unsigned long long data); michael@0: michael@0: /** michael@0: * This method writes the binary contents of the named value. The value will michael@0: * be created if it does not already exist. michael@0: * michael@0: * JavaScript callers should take care with the value passed to this method michael@0: * since it will be truncated from a JS string (unicode) to a ISO-Latin-1 michael@0: * string. (The binary data will be treated as an ISO-Latin-1 character michael@0: * string, which it is not). So, JavaScript callers should only pass michael@0: * character values in the range \u0000 to \u00FF, or else data loss will michael@0: * occur. michael@0: * michael@0: * @param name michael@0: * The name of the value to modify. michael@0: * @param data michael@0: * The data for the value to modify. michael@0: */ michael@0: void writeBinaryValue(in AString name, in ACString data); michael@0: michael@0: /** michael@0: * This method starts watching the key to see if any of its values have michael@0: * changed. The key must have been opened with mode including ACCESS_NOTIFY. michael@0: * If recurse is true, then this key and any of its descendant keys are michael@0: * watched. Otherwise, only this key is watched. michael@0: * michael@0: * @param recurse michael@0: * Indicates whether or not to also watch child keys. michael@0: */ michael@0: void startWatching(in boolean recurse); michael@0: michael@0: /** michael@0: * This method stops any watching of the key initiated by a call to michael@0: * startWatching. This method does nothing if the key is not being watched. michael@0: */ michael@0: void stopWatching(); michael@0: michael@0: /** michael@0: * This method returns true if the key is being watched for changes (i.e., michael@0: * if startWatching() was called). michael@0: */ michael@0: boolean isWatching(); michael@0: michael@0: /** michael@0: * This method returns true if the key has changed and false otherwise. michael@0: * This method will always return false if startWatching was not called. michael@0: */ michael@0: boolean hasChanged(); michael@0: };