RegistryValueKind RegistryValueKind RegistryValueKind RegistryValueKind Enum

Definición

Especifica los tipos de datos que se deben utilizar para almacenar valores en el Registro, o identifica el tipo de datos de un valor contenido en el Registro.Specifies the data types to use when storing values in the registry, or identifies the data type of a value in the registry.

public enum class RegistryValueKind
[System.Runtime.InteropServices.ComVisible(true)]
public enum RegistryValueKind
type RegistryValueKind = 
Public Enum RegistryValueKind
Herencia
RegistryValueKindRegistryValueKindRegistryValueKindRegistryValueKind
Atributos

Campos

Binary Binary Binary Binary 3

Datos binarios en cualquier formato.Binary data in any form. Este valor es equivalente al tipo de datos del Registro REG_BINARY de la API de Windows.This value is equivalent to the Windows API registry data type REG_BINARY.

DWord DWord DWord DWord 4

Un número binario de 32 bits.A 32-bit binary number. Este valor es equivalente al tipo de datos del Registro REG_DWORD de la API de Windows.This value is equivalent to the Windows API registry data type REG_DWORD.

ExpandString ExpandString ExpandString ExpandString 2

Una cadena terminada en nulo que contiene referencias no expandidas a variables de entorno, tales como %PATH%, que se expanden cuando se recupera el valor.A null-terminated string that contains unexpanded references to environment variables, such as %PATH%, that are expanded when the value is retrieved. Este valor es equivalente al tipo de datos del Registro REG_EXPAND_SZ de la API de Windows.This value is equivalent to the Windows API registry data type REG_EXPAND_SZ.

MultiString MultiString MultiString MultiString 7

Una matriz de cadenas terminadas en nulo, finalizada con dos caracteres null.An array of null-terminated strings, terminated by two null characters. Este valor es equivalente al tipo de datos del Registro REG_MULTI_SZ de la API de Windows.This value is equivalent to the Windows API registry data type REG_MULTI_SZ.

None None None None -1

Ningún tipo de datos.No data type.

QWord QWord QWord QWord 11

Número binario de 64 bits.A 64-bit binary number. Este valor es equivalente al tipo de datos del Registro REG_QWORD de la API de Windows.This value is equivalent to the Windows API registry data type REG_QWORD.

String String String String 1

Una cadena terminada en nulo.A null-terminated string. Este valor es equivalente al tipo de datos del Registro REG_SZ de la API de Windows.This value is equivalent to the Windows API registry data type REG_SZ.

Unknown Unknown Unknown Unknown 0

Un tipo de datos del Registro no admitido.An unsupported registry data type. Por ejemplo, el tipo de datos del Registro REG_RESOURCE_LIST de la API de Windows de Microsoft no se admite.For example, the Microsoft Windows API registry data type REG_RESOURCE_LIST is unsupported. Utilice este valor para especificar que el método SetValue(String, Object) debe determinar el tipo de dato adecuado al almacenar un par de nombre y valor en el Registro.Use this value to specify that the SetValue(String, Object) method should determine the appropriate registry data type when storing a name/value pair.

Ejemplos

En el ejemplo de código siguiente se crea una clave del registro y establece varios valores para esa clave, mediante RegistryValueKind para especificar los tipos de datos del registro.The following code example creates a registry key and sets several values for that key, using RegistryValueKind to specify the registry data types. El ejemplo se utiliza RegistryKey.GetValueKind para comprobar los tipos de datos del registro con el fin de recuperar los valores y mostrarlos.The example then uses RegistryKey.GetValueKind to check the registry data types, in order to retrieve the values and display them.

using namespace System;
using namespace Microsoft::Win32;
int main()
{
   
   // Delete and recreate the test key.
   Registry::CurrentUser->DeleteSubKey( "RegistryValueKindExample", false );
   RegistryKey ^ rk = 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", gcnew array<String^>{
      "One","Two","Three"
   }, RegistryValueKind::MultiString );
   rk->SetValue( "BinaryValue", gcnew array<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 the name/value pairs stored in the test key, with the
   // registry data type in parentheses.
   //
   array<String^>^valueNames = rk->GetValueNames();
   System::Collections::IEnumerator^ myEnum = valueNames->GetEnumerator();
   while ( myEnum->MoveNext() )
   {
      String^ s = safe_cast<String^>(myEnum->Current);
      RegistryValueKind rvk = rk->GetValueKind( s );
      switch ( rvk )
      {
         case RegistryValueKind::MultiString:
         {
            array<String^>^values = (array<String^>^)rk->GetValue( s );
            Console::Write( "\r\n {0} ({1}) =", s, rvk );
            for ( int i = 0; i < values->Length; i++ )
            {
               if (i != 0) Console::Write(",");
               Console::Write( " \"{0}\"", values[ i ] );

            }
            Console::WriteLine();
            break;
         }
         case RegistryValueKind::Binary:
         {
            array<Byte>^bytes = (array<Byte>^)rk->GetValue( s );
            Console::Write( "\r\n {0} ({1}) =", s, rvk );
            for ( int i = 0; i < bytes->Length; i++ )
            {
               
               // Display each byte as two hexadecimal digits.
               Console::Write( " {0:X2}", bytes[ i ] );

            }
            Console::WriteLine();
            break;
         }
         default:
            Console::WriteLine( "\r\n {0} ({1}) = {2}", s, rvk, rk->GetValue( s ) );
            break;
      }
   }
}
/*

This code example produces the following output:
 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.***]

*/
using System;
using Microsoft.Win32;

public class Example
{
    public static void Main()
    {
        // Delete and recreate the test key.
        Registry.CurrentUser.DeleteSubKey("RegistryValueKindExample", false);
        RegistryKey rk = 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.
        //
        string[] valueNames = rk.GetValueNames();
        foreach (string s in valueNames)
        {
            RegistryValueKind rvk = rk.GetValueKind(s);
            switch (rvk)
            {
                case RegistryValueKind.MultiString :
                    string[] values = (string[]) rk.GetValue(s);
                    Console.Write("\r\n {0} ({1}) =", s, rvk);
                    for (int i = 0; i < values.Length; i++)
                    {
                        if (i != 0) Console.Write(",");
                        Console.Write(" \"{0}\"", values[i]);
                    }
                    Console.WriteLine();
                    break;
                
                case RegistryValueKind.Binary :
                    byte[] bytes = (byte[]) rk.GetValue(s);
                    Console.Write("\r\n {0} ({1}) =", s, rvk);
                    for (int i = 0; i < bytes.Length; i++)
                    {
                        // Display each byte as two hexadecimal digits.
                        Console.Write(" {0:X2}", bytes[i]);
                    }
                    Console.WriteLine();
                    break;
                
                default :
                    Console.WriteLine("\r\n {0} ({1}) = {2}", s, rvk, rk.GetValue(s));
                    break;
            }
        }
    }
}
/*

This code example produces the following output:
 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.***]

*/
Imports System
Imports Microsoft.Win32
Imports Microsoft.VisualBasic

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 'Main
End Class 'Example

'
'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.***]

Comentarios

El RegistryValueKind enumeración define el conjunto de tipos de datos admite el registro y el valor que se usa para tipos no compatibles (desconocido).The RegistryValueKind enumeration defines the set of supported registry data types and the value that is used for unsupported types (Unknown). A partir de la .NET Framework 4.NET Framework 4, puede especificar para que no use un tipo de datos con ningún valor.Starting in the .NET Framework 4.NET Framework 4, you can specify not to use a data type with the None value.

Use el RegistryKey.GetValueKind método para determinar el tipo de datos de un valor de clave del registro antes de recuperar el valor.Use the RegistryKey.GetValueKind method to determine the data type of a registry key value before retrieving the value. Cuando se establece un valor de clave del registro, utilice el SetValue método para especificar explícitamente el tipo de datos del registro.When you set a registry key value, use the SetValue method to specify the registry data type explicitly.

Se aplica a

Consulte también: