Back to Devexpress

RegistryAccessPolicy.QueryValue Event

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

latest4.3 KB
Original Source

RegistryAccessPolicy.QueryValue Event

Fires when the DevExpress control attempts to read a value from a system registry key 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.ValueEventArgs> QueryValue
vb
Public Shared Event QueryValue As EventHandler(Of RegistryAccessPolicy.ValueEventArgs)

Event Data

The QueryValue event's data class is RegistryAccessPolicy.ValueEventArgs. 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.
NameGets the name of the value stored in a registry key.
OperationGets an operation on a key value in the system registry.

Remarks

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

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

csharp
static string privatePath = "SPECIFY_REGISTRY_PRIVATE_PATH";
static void Main() {
    Application.EnableVisualStyles();
    Application.SetCompatibleTextRenderingDefault(false);
    DevExpress.Data.Utils.RegistryAccessPolicy.QueryValue += RegistryAccessPolicy_QueryValue;
    Application.Run(new Form1());
}
static void RegistryAccessPolicy_QueryValue(object sender, DevExpress.Data.Utils.RegistryAccessPolicy.ValueEventArgs 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 DevExpress.Data.Utils.RegistryAccessPolicy.QueryValue, AddressOf RegistryAccessPolicy_QueryValue
    Application.Run(New Form1())
End Sub
Shared Sub RegistryAccessPolicy_QueryValue(ByVal sender As Object, ByVal e As DevExpress.Data.Utils.RegistryAccessPolicy.ValueEventArgs)
  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