RegistryKeyChangeEvent class
Applies to: desktop apps only
The RegistryKeyChangeEvent class represents changes to a specific key. The changes apply only to the key, not its subkeys. For more information about using the WMI registry event classes, see the Modifying the System Registry section. For code examples, see WMI Tasks: Registry.
The following syntax is simplified from Managed Object Format (MOF) code and includes all inherited properties. Properties and methods are in alphabetic order, not MOF order.
Syntax
class RegistryKeyChangeEvent : RegistryEvent
{
string Hive;
string KeyPath;
uint8 SECURITY_DESCRIPTOR[];
uint64 TIME_CREATED;
};
Members
The RegistryKeyChangeEvent class inherits from RegistryEvent. RegistryKeyChangeEvent also has these types of members:
Properties
The RegistryKeyChangeEvent class has these properties.
- Hive
-
- Data type: string
- Access type: Read-only
Name of the hive (subtree) that contains the key (or keys) that is changed. For example, HKEY_LOCAL_MACHINE. Changes to the HKEY_CLASSES_ROOT and HKEY_CURRENT_USER hives are not supported by RegistryEvent or classes derived from it, such as RegistryKeyChangeEvent.
- KeyPath
-
- Data type: string
- Access type: Read/write
Path to the registry key. For example, "SOFTWARE\Microsoft\WBEM\Scripting".
- SECURITY_DESCRIPTOR
-
- Data type: uint8 array
- Access type: Read-only
Descriptor that the event provider uses to determine which users can receive an event. This property is inherited from __Event. A NULL access control list (ACL) in the SECURITY_DESCRIPTOR grants unlimited access to all users. For more information, see Creating a Security Descriptor for a New Object.
Windows 2000: Not available. - TIME_CREATED
-
- Data type: uint64
- Access type: Read-only
Unique value that indicates the time when an event is generated. This is a 64-bit FILETIME value that represents the number of 100-nanosecond intervals after January 1, 1601. The information is in the Coordinated Universal Time (UTC) format. This property is inherited from __Event. To convert this value to other time formats, use the SWbemDateTime methods SetFileTime and GetFileTime. For more information, see WMI Tasks: Dates and Times.
Windows 2000: Not available.For more information about using uint64 values in scripts, see Scripting in WMI.
Remarks
Queries that provide a KeyPath must have backslashes escaped. For example,
wmiServices.ExecNotificationQuery(_
& "SELECT * FROM RegistryKeyChangeEvent _
& "WHERE Hive='HKEY_LOCAL_MACHINE' AND " _
& "KeyPath='SOFTWARE\\Microsoft'")
Registry provider classes, unlike most of the Win32 classes are located in the WMI root\default namespace.
Examples
For script code examples, see WMI Tasks for Scripts and Applications and the TechNet ScriptCenter Script Repository.
For C++ code examples, see WMI C++ Application Examples.
The following VBScript code example calls the asynchronous method SWbemServices.ExecNotificationQueryAsync to monitor changes in any values under the registry key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WBEM\Scripting. Note that the backslashes in the registry key are escaped by a backslash ("\"). For more information about asynchronous calls and security, see Making an Asynchronous Call with VBScript.
To see the operation of this script, execute the script and use a registry editor such as Regedit to change the Default Namespace value under this key. Be sure to change it back to the original value.
The following script runs until the computer is restarted, WMI is stopped, or the script is stopped. To stop the script manually, use Task Manager to stop the process. To stop it programmatically, use the Terminate method in the Win32_Process class.
Set wmiServices = GetObject("winmgmts:root/default") Set wmiSink = WScript.CreateObject( _ "WbemScripting.SWbemSink", "SINK_") wmiServices.ExecNotificationQueryAsync wmiSink, _ "SELECT * FROM RegistryKeyChangeEvent " _ & "WHERE Hive='HKEY_LOCAL_MACHINE' AND " _ & "KeyPath='SOFTWARE\\Microsoft\\WBEM\\Scripting'" WScript.Echo "Listening for Registry Key" _ & " Change Events..." & vbCrLf While(True) WScript.Sleep 1000 Wend Sub SINK_OnObjectReady(wmiObject, wmiAsyncContext) WScript.Echo "Received Registry Change Event" _ & vbCrLf & wmiObject.GetObjectText_() End Sub
Requirements
|
Minimum supported client | Windows 2000 Professional |
|---|---|
|
Minimum supported server | Windows 2000 Server |
|
Namespace |
\root\default |
|
MOF |
|
|
DLL |
|
See also
Send comments about this topic to Microsoft
Build date: 3/9/2012