Get the App
SLTechnology News&Howtos  ›  Development  › 

Example of problems with Array in VB.NET

Shulou Source: shulou.com Published: 2022-06-02 08:52:14 09月23日 Update

This article mainly introduces an example of Array in VB.NET, which has a certain reference value, and interested friends can refer to it. I hope you will gain a lot after reading this article.

This example requires a project reference:

Imports Microsoft.Win32 'purpose: registry operation Imports System.Security.AccessControl' purpose: access control

First of all, add permissions to the keys in the registry, which can be subdivided into 11 optional permission types, with the following parameters:

Select Case ComboBox1.Text Case "full control" ObjRegRight = RegistryRights.FullControl Case "query value" ObjRegRight = RegistryRights.QueryValues Case "set value" ObjRegRight = RegistryRights.SetValue Case "create subkey" ObjRegRight = RegistryRights.CreateSubKey Case "enumerate subitem" ObjRegRight = RegistryRights.EnumerateSubKeys Case "notify" ObjRegRight = RegistryRights.Notify Case "create link" ObjRegRight = RegistryRights.CreateLink Case "delete" ObjRegRight = RegistryRights.Delete Case "write DAC" ObjRegRight = RegistryRights.WriteKey Case " Write owner "ObjRegRight = RegistryRights.TakeOwnership Case" read control "ObjRegRight = RegistryRights.ReadPermissions End Select"

Each subdivision permission is divided into two access control types: "allow" and "deny".

Select Case ComboBox2.Text Case "allow" ObjRegAccess = AccessControlType.Allow Case "deny" ObjRegAccess = AccessControlType.Deny End Select

Here are the functions that increase the permissions of the registry key

In the following two functions, Account represents the system nt account Rights and ControlType are the above-mentioned permission type and access control type, respectively.

Private Sub AddRegistrySecurity (ByVal Str_FileName As String, ByVal Account As String, ByVal Rights As RegistryRights, ByVal ControlType As AccessControlType) Dim RegKey As RegistryRegistryKey = Registry.CurrentUser.CreateSubKey ("fill in the specific key address here") Dim RegkeyAcl As RegistrySecurity = RegKey.GetAccessControl () Dim AccessRule As RegistryAccessRule = New RegistryAccessRule (Account, Rights, ControlType) RegkeyAcl.AddAccessRule (AccessRule) RegKey.SetAccessControl (RegkeyAcl) RegKey.Close () End Sub

Here are the functions that remove the permissions of the registry key

Private Sub RemoveRegistrySecurity (ByVal Str_FileName As String, ByVal Account As String, ByVal Rights As RegistryRights, ByVal ControlType As AccessControlType) Dim RegKey As RegistryRegistryKey = Registry.CurrentUser.CreateSubKey ("fill in the specific key address here") Dim RegkeyAcl As RegistrySecurity = RegKey.GetAccessControl () Dim AccessRule As RegistryAccessRule = New RegistryAccessRule (Account, Rights, ControlType) RegkeyAcl.RemoveAccessRule (AccessRule) RegKey.SetAccessControl (RegkeyAcl) RegKey.Close () End Sub thank you for reading this article carefully I hope the article "examples of Array problems in VB.NET" shared by the editor will be helpful to you. At the same time, I also hope that you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Tags: Permissions controls registry articles types functions examples questions addresses subkeys values uses subdivisions above representatives values interests parameters and at the same time examples Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi Apple Shulou Information vpn MySQL