本文整理汇总了VB.NET中Microsoft.Win32.RegistryKey.GetValue方法的典型用法代码示例。如果您正苦于以下问题:VB.NET RegistryKey.GetValue方法的具体用法?VB.NET RegistryKey.GetValue怎么用?VB.NET RegistryKey.GetValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Win32.RegistryKey 的用法示例。
在下文中一共展示了RegistryKey.GetValue方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的VB.NET代码示例。
示例1: Example
' 导入命名空间
Imports Microsoft.Win32
Public Class Example
Public Shared Sub Main()
' Delete and recreate the test key.
Registry.CurrentUser.DeleteSubKey("RegistryValueOptionsExample", False)
Dim rk As RegistryKey = _
Registry.CurrentUser.CreateSubKey("RegistryValueOptionsExample")
' Add a value that contains an environment variable.
rk.SetValue("ExpandValue", "The path is %PATH%", _
RegistryValueKind.ExpandString)
' Retrieve the value, first without expanding the environment
' variable and then expanding it.
Console.WriteLine("Unexpanded: ""{0}""", _
rk.GetValue("ExpandValue", "No Value", _
RegistryValueOptions.DoNotExpandEnvironmentNames))
Console.WriteLine("Expanded: ""{0}""", rk.GetValue("ExpandValue"))
End Sub
End Class
开发者ID:VB.NET开发者,项目名称:Microsoft.Win32,代码行数:22,代码来源:RegistryKey.GetValue
示例2: Example
' 导入命名空间
Imports Microsoft.Win32
Public Class Example
Public Shared Sub Main()
' Delete and recreate the test key.
Registry.CurrentUser.DeleteSubKey("RegistryValueKindExample", False)
Dim rk As RegistryKey = Registry.CurrentUser.CreateSubKey("RegistryValueKindExample")
' Create name/value pairs.
' This overload supports QWord (long) values.
rk.SetValue("QuadWordValue", 42, RegistryValueKind.QWord)
' The following SetValue calls have the same effect as using the
' SetValue overload that does not specify RegistryValueKind.
'
rk.SetValue("DWordValue", 42, RegistryValueKind.DWord)
rk.SetValue("MultipleStringValue", New String() {"One", "Two", "Three"}, RegistryValueKind.MultiString)
rk.SetValue("BinaryValue", New Byte() {10, 43, 44, 45, 14, 255}, RegistryValueKind.Binary)
rk.SetValue("StringValue", "The path is %PATH%", RegistryValueKind.String)
' This overload supports setting expandable string values. Compare
' the output from this value with the previous string value.
rk.SetValue("ExpandedStringValue", "The path is %PATH%", RegistryValueKind.ExpandString)
' Display all name/value pairs stored in the test key, with each
' registry data type in parentheses.
'
Dim valueNames As String() = rk.GetValueNames()
Dim s As String
For Each s In valueNames
Dim rvk As RegistryValueKind = rk.GetValueKind(s)
Select Case rvk
Case RegistryValueKind.MultiString
Dim values As String() = CType(rk.GetValue(s), String())
Console.Write(vbCrLf & " {0} ({1}) =", s, rvk)
For i As Integer = 0 To values.Length - 1
If i <> 0 Then Console.Write(",")
Console.Write(" ""{0}""", values(i))
Next i
Console.WriteLine()
Case RegistryValueKind.Binary
Dim bytes As Byte() = CType(rk.GetValue(s), Byte())
Console.Write(vbCrLf & " {0} ({1}) =", s, rvk)
For i As Integer = 0 To bytes.Length - 1
' Display each byte as two hexadecimal digits.
Console.Write(" {0:X2}", bytes(i))
Next i
Console.WriteLine()
Case Else
Console.WriteLine(vbCrLf & " {0} ({1}) = {2}", s, rvk, rk.GetValue(s))
End Select
Next s
End Sub
End Class
'
'This code example produces the following output (some output is omitted):
'
' QuadWordValue (QWord) = 42
'
' DWordValue (DWord) = 42
'
' MultipleStringValue (MultiString) = "One", "Two", "Three"
'
' BinaryValue (Binary) = 0A 2B 2C 2D 0E FF
'
' StringValue (String) = The path is %PATH%
'
' ExpandedStringValue (ExpandString) = The path is C:\Program Files\Microsoft.NET\SDK\v2.0\Bin;
' [***The remainder of this output is omitted.***]
开发者ID:VB.NET开发者,项目名称:Microsoft.Win32,代码行数:74,代码来源:RegistryKey.GetValue
示例3: RegGetDef
' 导入命名空间
Imports Microsoft.Win32
Public Class RegGetDef
Public Shared Sub Main()
' Create a reference to a valid key. In order for this code to
' work, the indicated key must have been created previously.
' The key name is not case-sensitive.
Dim rk As RegistryKey = Registry.LocalMachine.OpenSubKey("Software\myTestKey", false)
' Get the value from the specified name/value pair in the key.
Dim valueName As String = "myTestValue"
Console.WriteLine("Retrieving registry value ...")
Console.WriteLine()
Dim o As Object = rk.GetValue(valueName)
Console.WriteLine("Object Type = " + o.GetType().FullName)
Console.WriteLine()
Select Case rk.GetValueKind(valueName)
Case RegistryValueKind.String
Case RegistryValueKind.ExpandString
Console.WriteLine("Value = " + o)
Case RegistryValueKind.Binary
For Each b As Byte In CType(o,Byte())
Console.Write("{0:x2} ", b)
Next b
Console.WriteLine()
Case RegistryValueKind.DWord
Console.WriteLine("Value = " + Convert.ToString(CType(o,Int32)))
Case RegistryValueKind.QWord
Console.WriteLine("Value = " + Convert.ToString(CType(o,Int64)))
Case RegistryValueKind.MultiString
For Each s As String In CType(o,String())
Console.Write("[{0:s}], ", s)
Next s
Console.WriteLine()
Case Else
Console.WriteLine("Value = (Unknown)")
End Select
' Attempt to retrieve a value that does not exist; the specified
' default value is returned.
Dim Def As String = rk.GetValue("notavalue", "The default to return")
Console.WriteLine()
Console.WriteLine(def)
rk.Close()
End Sub
End Class
'
' Output:
' Retrieving registry value ...
'
' Object Type = System.String
'
' Value = testData
'
'The default to return
开发者ID:VB.NET开发者,项目名称:Microsoft.Win32,代码行数:58,代码来源:RegistryKey.GetValue
示例4: Main
' 导入命名空间
Imports System
Imports Microsoft.win32
Imports System.Diagnostics
Imports System.Windows.Forms
Public Class Tester
Public Shared Sub Main
Dim m_LM As RegistryKey
Dim m_HW As RegistryKey
Dim m_Des As RegistryKey
Dim m_System As RegistryKey
Dim m_CPU As RegistryKey
Dim m_Info As RegistryKey
m_LM = Registry.LocalMachine
m_HW = m_LM.OpenSubKey("HARDWARE")
m_Des = m_HW.OpenSubKey("DESCRIPTION")
m_System = m_Des.OpenSubKey("SYSTEM")
m_CPU = m_System.OpenSubKey("CentralProcessor")
m_Info = m_CPU.OpenSubKey("0")
Console.WriteLine(m_Info.GetValue("VendorIdentifier"))
Console.WriteLine(m_Info.GetValue("ProcessorNameString"))
Console.WriteLine(m_Info.GetValue("Identifier"))
Console.WriteLine(m_Info.GetValue("~Mhz") & "MHz")
End Sub
End Class
开发者ID:VB程序员,项目名称:Microsoft.Win32,代码行数:31,代码来源:RegistryKey.GetValue
注:本文中的Microsoft.Win32.RegistryKey.GetValue方法示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论