1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/xpcom/ds/nsIWindowsRegKey.idl Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,332 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* vim:set ts=2 sw=2 sts=2 et cindent: */ 1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.9 + 1.10 +#include "nsISupports.idl" 1.11 + 1.12 +native HKEY(HKEY); 1.13 + 1.14 +/** 1.15 + * This interface is designed to provide scriptable access to the Windows 1.16 + * registry system ("With Great Power Comes Great Responsibility"). The 1.17 + * interface represents a single key in the registry. 1.18 + * 1.19 + * This interface is highly Win32 specific. 1.20 + */ 1.21 +[scriptable, uuid(2555b930-d64f-437e-9be7-0a2cb252c1f4)] 1.22 +interface nsIWindowsRegKey : nsISupports 1.23 +{ 1.24 + /** 1.25 + * Root keys. The values for these keys correspond to the values from 1.26 + * WinReg.h in the MS Platform SDK. The ROOT_KEY_ prefix corresponds to the 1.27 + * HKEY_ prefix in the MS Platform SDK. 1.28 + * 1.29 + * This interface is not restricted to using only these root keys. 1.30 + */ 1.31 + const unsigned long ROOT_KEY_CLASSES_ROOT = 0x80000000; 1.32 + const unsigned long ROOT_KEY_CURRENT_USER = 0x80000001; 1.33 + const unsigned long ROOT_KEY_LOCAL_MACHINE = 0x80000002; 1.34 + 1.35 + /** 1.36 + * Values for the mode parameter passed to the open and create methods. 1.37 + * The values defined here correspond to the REGSAM values defined in 1.38 + * WinNT.h in the MS Platform SDK, where ACCESS_ is replaced with KEY_. 1.39 + * 1.40 + * This interface is not restricted to using only these access types. 1.41 + */ 1.42 + const unsigned long ACCESS_BASIC = 0x00020000; 1.43 + const unsigned long ACCESS_QUERY_VALUE = 0x00000001; 1.44 + const unsigned long ACCESS_SET_VALUE = 0x00000002; 1.45 + const unsigned long ACCESS_CREATE_SUB_KEY = 0x00000004; 1.46 + const unsigned long ACCESS_ENUMERATE_SUB_KEYS = 0x00000008; 1.47 + const unsigned long ACCESS_NOTIFY = 0x00000010; 1.48 + const unsigned long ACCESS_READ = ACCESS_BASIC | 1.49 + ACCESS_QUERY_VALUE | 1.50 + ACCESS_ENUMERATE_SUB_KEYS | 1.51 + ACCESS_NOTIFY; 1.52 + const unsigned long ACCESS_WRITE = ACCESS_BASIC | 1.53 + ACCESS_SET_VALUE | 1.54 + ACCESS_CREATE_SUB_KEY; 1.55 + const unsigned long ACCESS_ALL = ACCESS_READ | 1.56 + ACCESS_WRITE; 1.57 + const unsigned long WOW64_32 = 0x00000200; 1.58 + const unsigned long WOW64_64 = 0x00000100; 1.59 + 1.60 + 1.61 + /** 1.62 + * Values for the type of a registry value. The numeric values of these 1.63 + * constants are taken directly from WinNT.h in the MS Platform SDK. 1.64 + * The Microsoft documentation should be consulted for the exact meaning of 1.65 + * these value types. 1.66 + * 1.67 + * This interface is somewhat restricted to using only these value types. 1.68 + * There is no method that is directly equivalent to RegQueryValueEx or 1.69 + * RegSetValueEx. In particular, this interface does not support the 1.70 + * REG_MULTI_SZ and REG_EXPAND_SZ value types. It is still possible to 1.71 + * enumerate values that have other types (i.e., getValueType may return a 1.72 + * type not defined below). 1.73 + */ 1.74 + const unsigned long TYPE_NONE = 0; // REG_NONE 1.75 + const unsigned long TYPE_STRING = 1; // REG_SZ 1.76 + const unsigned long TYPE_BINARY = 3; // REG_BINARY 1.77 + const unsigned long TYPE_INT = 4; // REG_DWORD 1.78 + const unsigned long TYPE_INT64 = 11; // REG_QWORD 1.79 + 1.80 + /** 1.81 + * This attribute exposes the native HKEY and is available to provide C++ 1.82 + * consumers with the flexibility of making other Windows registry API calls 1.83 + * that are not exposed via this interface. 1.84 + * 1.85 + * It is possible to initialize this object by setting an HKEY on it. In 1.86 + * that case, it is the responsibility of the consumer setting the HKEY to 1.87 + * ensure that it is a valid HKEY. 1.88 + * 1.89 + * WARNING: Setting the key does not close the old key. 1.90 + */ 1.91 + [noscript] attribute HKEY key; 1.92 + 1.93 + /** 1.94 + * This method closes the key. If the key is already closed, then this 1.95 + * method does nothing. 1.96 + */ 1.97 + void close(); 1.98 + 1.99 + /** 1.100 + * This method opens an existing key. This method fails if the key 1.101 + * does not exist. 1.102 + * 1.103 + * NOTE: On 32-bit Windows, it is valid to pass any HKEY as the rootKey 1.104 + * parameter of this function. However, for compatibility with 64-bit 1.105 + * Windows, that usage should probably be avoided in favor of openChild. 1.106 + * 1.107 + * @param rootKey 1.108 + * A root key defined above or any valid HKEY on 32-bit Windows. 1.109 + * @param relPath 1.110 + * A relative path from the given root key. 1.111 + * @param mode 1.112 + * Access mode, which is a bit-wise OR of the ACCESS_ values defined 1.113 + * above. 1.114 + */ 1.115 + void open(in unsigned long rootKey, in AString relPath, in unsigned long mode); 1.116 + 1.117 + /** 1.118 + * This method opens an existing key or creates a new key. 1.119 + * 1.120 + * NOTE: On 32-bit Windows, it is valid to pass any HKEY as the rootKey 1.121 + * parameter of this function. However, for compatibility with 64-bit 1.122 + * Windows, that usage should probably be avoided in favor of createChild. 1.123 + * 1.124 + * @param rootKey 1.125 + * A root key defined above or any valid HKEY on 32-bit Windows. 1.126 + * @param relPath 1.127 + * A relative path from the given root key. 1.128 + * @param mode 1.129 + * Access mode, which is a bit-wise OR of the ACCESS_ values defined 1.130 + * above. 1.131 + */ 1.132 + void create(in unsigned long rootKey, in AString relPath, in unsigned long mode); 1.133 + 1.134 + /** 1.135 + * This method opens a subkey relative to this key. This method fails if the 1.136 + * key does not exist. 1.137 + * 1.138 + * @return nsIWindowsRegKey for the newly opened subkey. 1.139 + */ 1.140 + nsIWindowsRegKey openChild(in AString relPath, in unsigned long mode); 1.141 + 1.142 + /** 1.143 + * This method opens or creates a subkey relative to this key. 1.144 + * 1.145 + * @return nsIWindowsRegKey for the newly opened or created subkey. 1.146 + */ 1.147 + nsIWindowsRegKey createChild(in AString relPath, in unsigned long mode); 1.148 + 1.149 + /** 1.150 + * This attribute returns the number of child keys. 1.151 + */ 1.152 + readonly attribute unsigned long childCount; 1.153 + 1.154 + /** 1.155 + * This method returns the name of the n'th child key. 1.156 + * 1.157 + * @param index 1.158 + * The index of the requested child key. 1.159 + */ 1.160 + AString getChildName(in unsigned long index); 1.161 + 1.162 + /** 1.163 + * This method checks to see if the key has a child by the given name. 1.164 + * 1.165 + * @param name 1.166 + * The name of the requested child key. 1.167 + */ 1.168 + boolean hasChild(in AString name); 1.169 + 1.170 + /** 1.171 + * This attribute returns the number of values under this key. 1.172 + */ 1.173 + readonly attribute unsigned long valueCount; 1.174 + 1.175 + /** 1.176 + * This method returns the name of the n'th value under this key. 1.177 + * 1.178 + * @param index 1.179 + * The index of the requested value. 1.180 + */ 1.181 + AString getValueName(in unsigned long index); 1.182 + 1.183 + /** 1.184 + * This method checks to see if the key has a value by the given name. 1.185 + * 1.186 + * @param name 1.187 + * The name of the requested value. 1.188 + */ 1.189 + boolean hasValue(in AString name); 1.190 + 1.191 + /** 1.192 + * This method removes a child key and all of its values. This method will 1.193 + * fail if the key has any children of its own. 1.194 + * 1.195 + * @param relPath 1.196 + * The relative path from this key to the key to be removed. 1.197 + */ 1.198 + void removeChild(in AString relPath); 1.199 + 1.200 + /** 1.201 + * This method removes the value with the given name. 1.202 + * 1.203 + * @param name 1.204 + * The name of the value to be removed. 1.205 + */ 1.206 + void removeValue(in AString name); 1.207 + 1.208 + /** 1.209 + * This method returns the type of the value with the given name. The return 1.210 + * value is one of the "TYPE_" constants defined above. 1.211 + * 1.212 + * @param name 1.213 + * The name of the value to query. 1.214 + */ 1.215 + unsigned long getValueType(in AString name); 1.216 + 1.217 + /** 1.218 + * This method reads the string contents of the named value as a Unicode 1.219 + * string. 1.220 + * 1.221 + * @param name 1.222 + * The name of the value to query. This parameter can be the empty 1.223 + * string to request the key's default value. 1.224 + */ 1.225 + AString readStringValue(in AString name); 1.226 + 1.227 + /** 1.228 + * This method reads the integer contents of the named value. 1.229 + * 1.230 + * @param name 1.231 + * The name of the value to query. 1.232 + */ 1.233 + unsigned long readIntValue(in AString name); 1.234 + 1.235 + /** 1.236 + * This method reads the 64-bit integer contents of the named value. 1.237 + * 1.238 + * @param name 1.239 + * The name of the value to query. 1.240 + */ 1.241 + unsigned long long readInt64Value(in AString name); 1.242 + 1.243 + /** 1.244 + * This method reads the binary contents of the named value under this key. 1.245 + * 1.246 + * JavaScript callers should take care with the result of this method since 1.247 + * it will be byte-expanded to form a JS string. (The binary data will be 1.248 + * treated as an ISO-Latin-1 character string, which it is not). 1.249 + * 1.250 + * @param name 1.251 + * The name of the value to query. 1.252 + */ 1.253 + ACString readBinaryValue(in AString name); 1.254 + 1.255 + /** 1.256 + * This method writes the unicode string contents of the named value. The 1.257 + * value will be created if it does not already exist. 1.258 + * 1.259 + * @param name 1.260 + * The name of the value to modify. This parameter can be the empty 1.261 + * string to modify the key's default value. 1.262 + * @param data 1.263 + * The data for the value to modify. 1.264 + */ 1.265 + void writeStringValue(in AString name, in AString data); 1.266 + 1.267 + /** 1.268 + * This method writes the integer contents of the named value. The value 1.269 + * will be created if it does not already exist. 1.270 + * 1.271 + * @param name 1.272 + * The name of the value to modify. 1.273 + * @param data 1.274 + * The data for the value to modify. 1.275 + */ 1.276 + void writeIntValue(in AString name, in unsigned long data); 1.277 + 1.278 + /** 1.279 + * This method writes the 64-bit integer contents of the named value. The 1.280 + * value will be created if it does not already exist. 1.281 + * 1.282 + * @param name 1.283 + * The name of the value to modify. 1.284 + * @param data 1.285 + * The data for the value to modify. 1.286 + */ 1.287 + void writeInt64Value(in AString name, in unsigned long long data); 1.288 + 1.289 + /** 1.290 + * This method writes the binary contents of the named value. The value will 1.291 + * be created if it does not already exist. 1.292 + * 1.293 + * JavaScript callers should take care with the value passed to this method 1.294 + * since it will be truncated from a JS string (unicode) to a ISO-Latin-1 1.295 + * string. (The binary data will be treated as an ISO-Latin-1 character 1.296 + * string, which it is not). So, JavaScript callers should only pass 1.297 + * character values in the range \u0000 to \u00FF, or else data loss will 1.298 + * occur. 1.299 + * 1.300 + * @param name 1.301 + * The name of the value to modify. 1.302 + * @param data 1.303 + * The data for the value to modify. 1.304 + */ 1.305 + void writeBinaryValue(in AString name, in ACString data); 1.306 + 1.307 + /** 1.308 + * This method starts watching the key to see if any of its values have 1.309 + * changed. The key must have been opened with mode including ACCESS_NOTIFY. 1.310 + * If recurse is true, then this key and any of its descendant keys are 1.311 + * watched. Otherwise, only this key is watched. 1.312 + * 1.313 + * @param recurse 1.314 + * Indicates whether or not to also watch child keys. 1.315 + */ 1.316 + void startWatching(in boolean recurse); 1.317 + 1.318 + /** 1.319 + * This method stops any watching of the key initiated by a call to 1.320 + * startWatching. This method does nothing if the key is not being watched. 1.321 + */ 1.322 + void stopWatching(); 1.323 + 1.324 + /** 1.325 + * This method returns true if the key is being watched for changes (i.e., 1.326 + * if startWatching() was called). 1.327 + */ 1.328 + boolean isWatching(); 1.329 + 1.330 + /** 1.331 + * This method returns true if the key has changed and false otherwise. 1.332 + * This method will always return false if startWatching was not called. 1.333 + */ 1.334 + boolean hasChanged(); 1.335 +};