本文整理汇总了VB.NET中Microsoft.Win32.RegistryKeyPermissionCheck枚举的典型用法代码示例。如果您正苦于以下问题:VB.NET RegistryKeyPermissionCheck枚举的具体用法?VB.NET RegistryKeyPermissionCheck怎么用?VB.NET RegistryKeyPermissionCheck使用的例子?那么恭喜您, 这里精选的枚举代码示例或许可以为您提供帮助。
在下文中一共展示了RegistryKeyPermissionCheck枚举的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1: Example
' 导入命名空间
Imports Microsoft.Win32
Imports System.Diagnostics
Public Class Example
Public Shared Sub Main()
Const LIMIT As Integer = 100
Dim cu As RegistryKey = Registry.CurrentUser
Const testKey As String = "RegistryKeyPermissionCheckExample"
Console.WriteLine("Generating {0} key/value pairs.", LIMIT)
Dim rk As RegistryKey = cu.CreateSubKey(testKey)
For i As Integer = 0 To LIMIT
rk.SetValue("Key" & i, i)
Next i
rk.Close()
Dim s As New Stopwatch()
' On the default setting, security is checked every time
' a key/value pair is read.
rk = cu.OpenSubKey(testKey, _
RegistryKeyPermissionCheck.Default)
s.Start()
For i As Integer = 0 To LIMIT
rk.GetValue("Key" & i, i)
Next i
s.Stop()
rk.Close()
Dim delta1 As Long = s.ElapsedTicks
s.Reset()
' When the key is opened with ReadSubTree, security is
' not checked when the values are read.
rk = cu.OpenSubKey(testKey, _
RegistryKeyPermissionCheck.ReadSubTree)
s.Start()
For i As Integer = 0 To LIMIT
rk.GetValue("Key" & i, i)
Next i
s.Stop()
rk.Close()
Dim delta2 As Long = s.ElapsedTicks
Dim faster As Double = _
CDbl(delta1 - delta2) * 100.0 / CDbl(delta1)
Console.WriteLine("ReadSubTree is {0}% faster for {1} values.", _
faster.ToString("0.0"), LIMIT)
cu.DeleteSubKey(testKey)
End Sub
End Class
输出:
Generating 100 key/value pairs. ReadSubTree is 23.4% faster for 100 values.