Back to Devexpress

RegistryAccessPolicy.EnumerateSubKeyTree Event

corelibraries-devexpress-dot-data-dot-utils-dot-registryaccesspolicy-a4bfa793.md

latest4.2 KB
Original Source

RegistryAccessPolicy.EnumerateSubKeyTree Event

Fires when the DevExpress control attempts to iterate subkey values in the system registry and allows you to cancel the operation.

Namespace : DevExpress.Data.Utils

Assembly : DevExpress.Data.Desktop.v25.2.dll

NuGet Packages : DevExpress.Data.Desktop, DevExpress.ExpressApp.Win.Design

Declaration

csharp
public static event EventHandler<RegistryAccessPolicy.QuerySubKeyTreeOperationEventArgs> EnumerateSubKeyTree
vb
Public Shared Event EnumerateSubKeyTree As EventHandler(Of RegistryAccessPolicy.QuerySubKeyTreeOperationEventArgs)

Event Data

The EnumerateSubKeyTree event's data class is RegistryAccessPolicy.QuerySubKeyTreeOperationEventArgs. The following properties provide information specific to this event:

PropertyDescription
CancelGets or sets a value indicating whether the event should be canceled. Inherited from CancelEventArgs.
HiveGets a registry hive (a logical group of keys, subkeys, and values in the registry). Inherited from RegistryAccessPolicy.RegistryOperationBaseEventArgs.
KeyGets the requested registry key. Inherited from RegistryAccessPolicy.RegistryOperationBaseEventArgs.
OperationGets the operation performed on the subkey.

Remarks

Set the e.Cancel event parameter to true to cancel the operation. e.Hive and e.Key event parameters identify a registry hive and key.

The following example suppresses attempts to enumerate subkey values from the specified system registry path:

csharp
static string privatePath = "SPECIFY_REGISTRY_PRIVATE_PATH";
static void Main() {
    Application.EnableVisualStyles();
    Application.SetCompatibleTextRenderingDefault(false);
    RegistryAccessPolicy.EnumerateSubKeyTree += RegistryAccessPolicy_EnumerateSubKeyTree;
    Application.Run(new Form1());
}
static void RegistryAccessPolicy_EnumerateSubKeyTree(object sender, RegistryAccessPolicy.QuerySubKeyTreeOperationEventArgs e) {
    e.Cancel = e.Key.Contains(privatePath);
}
vb
Private Shared privatePath As String = "SPECIFY_REGISTRY_PRIVATE_PATH"
Shared Sub Main()
    Application.EnableVisualStyles()
    Application.SetCompatibleTextRenderingDefault(False)
    AddHandler RegistryAccessPolicy.EnumerateSubKeyTree, AddressOf RegistryAccessPolicy_EnumerateSubKeyTree
    Application.Run(New Form1())
End Sub
Shared Sub RegistryAccessPolicy_EnumerateSubKeyTree(ByVal sender As Object, ByVal e As RegistryAccessPolicy.QuerySubKeyTreeOperationEventArgs)
    e.Cancel = e.Key.Contains(privatePath)
End Sub

Read the following topic for additional information: Registry Access Policy.

See Also

RegistryAccessPolicy Class

RegistryAccessPolicy Members

DevExpress.Data.Utils Namespace