nsIWindowsRegKey 编辑
xpcom/ds/nsIWindowsRegKey.idl
Scriptable This interface is designed to provide scriptable access to the Windows registry system. 1.0 66 Introduced Gecko 1.8 Inherits from: nsISupports
Last changed in Gecko 1.8 (Firefox 1.5 / Thunderbird 1.5 / SeaMonkey 1.0)The interface represents a single key
in the registry.
This interface is highly Win32 specific.
Method overview
void close(); |
void create(in unsigned long rootKey, in AString relPath, in unsigned long mode); |
nsIWindowsRegKey createChild(in AString relPath, in unsigned long mode); |
AString getChildName(in unsigned long index); |
AString getValueName(in unsigned long index); |
unsigned long getValueType(in AString name); |
boolean hasChanged(); |
boolean hasChild(in AString name); |
boolean hasValue(in AString name); |
boolean isWatching(); |
void open(in unsigned long rootKey, in AString relPath, in unsigned long mode); |
nsIWindowsRegKey openChild(in AString relPath, in unsigned long mode); |
ACString readBinaryValue(in AString name); |
unsigned long long readInt64Value(in AString name); |
unsigned long readIntValue(in AString name); |
AString readStringValue(in AString name); |
void removeChild(in AString relPath); |
void removeValue(in AString name); |
void startWatching(in boolean recurse); |
void stopWatching(); |
void writeBinaryValue(in AString name, in ACString data); |
void writeInt64Value(in AString name, in unsigned long long data); |
void writeIntValue(in AString name, in unsigned long data); |
void writeStringValue(in AString name, in AString data); |
Attributes
Attribute | Type | Description |
childCount | unsigned long | This attribute returns the number of child keys. Read only. |
key | HKEY | This attribute exposes the native HKEY and is available to provide C++ consumers with the flexibility of making other Windows registry API calls that are not exposed via this interface. It is possible to initialize this object by setting an HKEY on it. In that case, it is the responsibility of the consumer setting the HKEY to ensure that it is a valid HKEY. WARNING: Setting thekey does not close() the old key . Native code only! |
valueCount | unsigned long | This attribute returns the number of values under this key . Read only. |
Constants
Root key constants
The values for these keys correspond to the values from WinReg.h in the MS Platform SDK. The ROOT_KEY_ prefix corresponds to the HKEY_ prefix in the MS Platform SDK.
This interface is not restricted to using only these root keys.
Constant | Value | Description |
ROOT_KEY_CLASSES_ROOT | 0x80000000 | |
ROOT_KEY_CURRENT_USER | 0x80000001 | |
ROOT_KEY_LOCAL_MACHINE | 0x80000002 |
Access constants
Values for the mode parameter passed to the open()
and create()
methods. The values defined here correspond to the REGSAM values defined in WinNT.h
in the MS Platform SDK, where ACCESS_
is replaced with KEY_
.
This interface is not restricted to using only these access types.
Constant | Value | Description |
ACCESS_BASIC | 0x00020000 | |
ACCESS_QUERY_VALUE | 0x00000001 | |
ACCESS_SET_VALUE | 0x00000002 | |
ACCESS_CREATE_SUB_KEY | 0x00000004 | |
ACCESS_ENUMERATE_SUB_KEYS | 0x00000008 | |
ACCESS_NOTIFY | 0x00000010 | |
ACCESS_READ | ACCESS_BASIC | ACCESS_QUERY_VALUE | ACCESS_ENUMERATE_SUB_KEYS | ACCESS_NOTIFY | |
ACCESS_WRITE | ACCESS_BASIC | ACCESS_SET_VALUE | ACCESS_CREATE_SUB_KEY | |
ACCESS_ALL | ACCESS_READ | ACCESS_WRITE | |
WOW64_32 | 0x00000200 | |
WOW64_64 | 0x00000100 |
Type constants
Values for the type of a registry value. The numeric values of these constants are taken directly from WinNT.h in the MS Platform SDK. The Microsoft documentation should be consulted for the exact meaning of these value types.
This interface is somewhat restricted to using only these value types. There is no method that is directly equivalent to RegQueryValueEx or RegSetValueEx. In particular, this interface does not support the REG_MULTI_SZ and REG_EXPAND_SZ value types. It is still possible to enumerate values that have other types (that is, getValueType()
may return a type not defined below).
Constant | Value | Description |
TYPE_NONE | 0 | REG_NONE |
TYPE_STRING | 1 | REG_SZ |
TYPE_BINARY | 3 | REG_BINARY |
TYPE_INT | 4 | REG_DWORD |
TYPE_INT64 | 11 | REG_QWORD |
Methods
close()
This method closes the key
. If the key
is already closed, then this method does nothing.
void close();
Parameters
None.
create()
This method opens an existing key
or creates a new key
.
createChild()
.void create( in unsigned long rootKey, in AString relPath, in unsigned long mode );
Parameters
rootKey
- A root
key
defined above or any valid HKEY on 32-bit Windows. relPath
- A relative path from the given root
key
. mode
- Access mode, which is a bit-wise OR of the ACCESS_ values defined above.
createChild()
This method opens or creates a subkey relative to this key
.
nsIWindowsRegKey createChild( in AString relPath, in unsigned long mode );
Parameters
relPath
mode
Return value
nsIWindowsRegKey
for the newly opened or created subkey.
getChildName()
This method returns the name of the n'th child key
.
AString getChildName( in unsigned long index );
Parameters
index
- The index of the requested child
key
.
Return value
The name of the n'th child key
.
getValueName()
This method returns the name of the n'th value under this key
.
AString getValueName( in unsigned long index );
Parameters
index
- The index of the requested value.
Return value
The name of the n'th value under this key
.
getValueType()
This method returns the type of the value with the given name.
unsigned long getValueType( in AString name );
Parameters
name
- The name of the value to query.
Return value
One of the "TYPE_" constants.
hasChanged()
boolean hasChanged();
Parameters
None.
Return value
This method returns true
if the key
has changed and false
otherwise. This method will always return false
if startWatching()
was not called.
hasChild()
This method checks to see if the key
has a child by the given name.
boolean hasChild( in AString name );
Parameters
name
- The name of the requested child
key
.
Return value
true
if the key
has a child by the given name.
hasValue()
This method checks to see if the key
has a value by the given name.
boolean hasValue( in AString name );
Parameters
name
- The name of the requested value.
Return value
true
if the key
has a value by the given name.
isWatching()
This method returns true
if the key
is being watched for changes (that is, if startWatching()
was called).
boolean isWatching();
Parameters
None.
Return value
true
if the key
is being watched for changes.
open()
This method opens an existing key
. This method fails if the key
does not exist.
openChild()
.void open( in unsigned long rootKey, in AString relPath, in unsigned long mode );
Parameters
rootKey
- A root
key
defined above or any valid HKEY on 32-bit Windows. relPath
- A relative path from the given root
key
. mode
- Access mode, which is a bit-wise OR of the ACCESS_ values defined above.
openChild()
This method opens a subkey relative to this key
. This method fails if the key
does not exist.
nsIWindowsRegKey openChild( in AString relPath, in unsigned long mode );
Parameters
relPath
mode
Return value
nsIWindowsRegKey
for the newly opened subkey.
readBinaryValue()
This method reads the binary contents of the named value under this key
.
JavaScript callers should take care with the result of this method since it will be byte-expanded to form a JS string. (The binary data will be treated as an ISO-Latin-1 character string, which it is not).
ACString readBinaryValue( in AString name );
Parameters
name
- The name of the value to query.
Return value
The binary contents of the named value under this key
.
readInt64Value()
This method reads the 64-bit integer contents of the named value.
unsigned long long readInt64Value( in AString name );
Parameters
name
- The name of the value to query.
Return value
The 64-bit integer contents of the named value.
readIntValue()
This method reads the integer contents of the named value.
unsigned long readIntValue( in AString name );
Parameters
name
- The name of the value to query.
Return value
The integer contents of the named value.
readStringValue()
This method reads the string contents of the named value as a Unicode string.
AString readStringValue( in AString name );
Parameters
name
- The name of the value to query. This parameter can be the empty string to request the
key
's default value.
Return value
The string contents of the named value as a Unicode string.
Note: UnlikewriteStringValue()
, readStringValue()
will work with REG_MULTI_SZ
and REG_EXPAND_SZ
types.Note: In Gecko 2.0, readStringValue()
calls ExpandEnvironmentStrings()
on a REG_EXPAND_SZ
type.
removeChild()
This method removes a child key
and all of its values. This method will fail if the key
has any children of its own.
void removeChild( in AString relPath );
Parameters
relPath
- The relative path from this
key
to thekey
to be removed.
removeValue()
This method removes the value with the given name.
void removeValue( in AString name );
Parameters
name
- The name of the value to be removed.
startWatching()
This method starts watching the key
to see if any of its values have changed. The key
must have been opened with mode including ACCESS_NOTIFY
. If recurse is true
, then this key
and any of its descendant keys are watched. Otherwise, only this key
is watched.
void startWatching( in boolean recurse );
Parameters
recurse
- Indicates whether or not to also watch child keys.
stopWatching()
This method stops any watching of the key
initiated by a call to startWatching()
. This method does nothing if the key
is not being watched.
void stopWatching();
Parameters
None.
writeBinaryValue()
This method writes the binary contents of the named value. The value will be created if it does not already exist.
JavaScript callers should take care with the value passed to this method since it will be truncated from a JS string (unicode) to a ISO-Latin-1 string. (The binary data will be treated as an ISO-Latin-1 character string, which it is not). So, JavaScript callers should only pass character values in the range \u0000 to \u00FF, or else data loss will occur.
void writeBinaryValue( in AString name, in ACString data );
Parameters
name
- The name of the value to modify.
data
- The data for the value to modify.
writeInt64Value()
This method writes the 64-bit integer contents of the named value. The value will be created if it does not already exist.
void writeInt64Value( in AString name, in unsigned long long data );
Parameters
name
- The name of the value to modify.
data
- The data for the value to modify.
writeIntValue()
This method writes the integer contents of the named value. The value will be created if it does not already exist.
void writeIntValue( in AString name, in unsigned long data );
Parameters
name
- The name of the value to modify.
data
- The data for the value to modify.
writeStringValue()
This method writes the unicode string contents of the named value. The value will be created if it does not already exist.
void writeStringValue( in AString name, in AString data );
Parameters
name
- The name of the value to modify. This parameter can be the empty string to modify the
key
's default value. data
- The data for the value to modify.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论