RegistryHive Перечисление
Определение
Важно!
Некоторые сведения относятся к предварительной версии продукта, в которую до выпуска могут быть внесены существенные изменения. Майкрософт не предоставляет никаких гарантий, явных или подразумеваемых, относительно приведенных здесь сведений.
Представляет возможные значения узла верхнего уровня на иностранном компьютере.
public enum class RegistryHive
[System.Serializable]
public enum RegistryHive
[System.Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
public enum RegistryHive
[<System.Serializable>]
type RegistryHive =
[<System.Serializable>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type RegistryHive =
Public Enum RegistryHive
- Наследование
- Атрибуты
Поля
| Имя | Значение | Описание |
|---|---|---|
| ClassesRoot | -2147483648 | Представляет базовый ключ HKEY_CLASSES_ROOT на другом компьютере. Это значение можно передать методу OpenRemoteBaseKey(RegistryHive, String) , чтобы удаленно открыть этот узел. |
| CurrentUser | -2147483647 | Представляет базовый ключ HKEY_CURRENT_USER на другом компьютере. Это значение можно передать методу OpenRemoteBaseKey(RegistryHive, String) , чтобы удаленно открыть этот узел. |
| LocalMachine | -2147483646 | Представляет базовый ключ HKEY_LOCAL_MACHINE на другом компьютере. Это значение можно передать методу OpenRemoteBaseKey(RegistryHive, String) , чтобы удаленно открыть этот узел. |
| Users | -2147483645 | Представляет базовый ключ HKEY_USERS на другом компьютере. Это значение можно передать методу OpenRemoteBaseKey(RegistryHive, String) , чтобы удаленно открыть этот узел. |
| PerformanceData | -2147483644 | Представляет базовый ключ HKEY_PERFORMANCE_DATA на другом компьютере. Это значение можно передать методу OpenRemoteBaseKey(RegistryHive, String) , чтобы удаленно открыть этот узел. |
| CurrentConfig | -2147483643 | Представляет базовый ключ HKEY_CURRENT_CONFIG на другом компьютере. Это значение можно передать методу OpenRemoteBaseKey(RegistryHive, String) , чтобы удаленно открыть этот узел. |
| DynData | -2147483642 | Представляет базовый ключ HKEY_DYN_DATA на другом компьютере. Это значение можно передать методу OpenRemoteBaseKey(RegistryHive, String) , чтобы удаленно открыть этот узел. |
Примеры
В следующем примере кода показано, как открыть раздел реестра на удаленном компьютере и перечислить значения ключа. Удаленный компьютер должен запускать службу удаленного реестра. Укажите имя удаленного компьютера в качестве аргумента командной строки при вызове программы.
using namespace System;
using namespace System::IO;
using namespace System::Security::Permissions;
using namespace Microsoft::Win32;
int main( int argc, char *argv[] )
{
RegistryKey ^ environmentKey;
// Check that an argument was specified when the
// program was invoked.
if ( argc == 1 )
{
Console::WriteLine( "Error: The name of the remote computer "
"must be specified as input on the command line." );
return -1;
}
try
{
// Open HKEY_CURRENT_USER\Environment on a remote computer.
environmentKey = RegistryKey::OpenRemoteBaseKey( RegistryHive::CurrentUser, gcnew String(argv[ 1 ]) )->OpenSubKey( "Environment" );
}
catch ( IOException^ e )
{
Console::WriteLine( "{0}: {1}", e->GetType()->Name, e->Message );
return -1;
}
// Print the values.
Console::WriteLine( "\nThere are {0} values for {1}.", environmentKey->ValueCount.ToString(), environmentKey->Name );
array<String^>^valueNames = environmentKey->GetValueNames();
for ( int i = 0; i < environmentKey->ValueCount; i++ )
{
Console::WriteLine( "{0,-20}: {1}", valueNames[ i ], environmentKey->GetValue( valueNames[ i ] )->ToString() );
}
// Close the registry key.
environmentKey->Close();
}
using System;
using System.IO;
using System.Security.Permissions;
using Microsoft.Win32;
class RemoteKey
{
static void Main(string[] args)
{
RegistryKey environmentKey;
string remoteName;
// Check that an argument was specified when the
// program was invoked.
if(args.Length == 0)
{
Console.WriteLine("Error: The name of the remote " +
"computer must be specified when the program is " +
"invoked.");
return;
}
else
{
remoteName = args[0];
}
try
{
// Open HKEY_CURRENT_USER\Environment
// on a remote computer.
environmentKey = RegistryKey.OpenRemoteBaseKey(
RegistryHive.CurrentUser, remoteName).OpenSubKey(
"Environment");
}
catch(IOException e)
{
Console.WriteLine("{0}: {1}",
e.GetType().Name, e.Message);
return;
}
// Print the values.
Console.WriteLine("\nThere are {0} values for {1}.",
environmentKey.ValueCount.ToString(),
environmentKey.Name);
foreach(string valueName in environmentKey.GetValueNames())
{
Console.WriteLine("{0,-20}: {1}", valueName,
environmentKey.GetValue(valueName).ToString());
}
// Close the registry key.
environmentKey.Close();
}
}
Imports System.IO
Imports System.Security.Permissions
Imports Microsoft.Win32
Public Class RemoteKey
Shared Sub Main(commandLineArgs As String())
Dim environmentKey As RegistryKey
' Check that an argument was specified when the
' program was invoked.
If commandLineArgs.Length = 0 Then
Console.WriteLine("Error: The name of the remote " & _
"computer must be specified as input on the " & _
"command line.")
Return
End If
Try
' Open HKEY_CURRENT_USER\Environment on a remote computer.
environmentKey = RegistryKey.OpenRemoteBaseKey( _
RegistryHive.CurrentUser, _
commandLineArgs(0)).OpenSubKey("Environment")
Catch ex As IOException
Console.WriteLine("{0}: {1}", _
ex.GetType().Name, ex.Message)
Return
End Try
' Print the values.
Console.WriteLine("\nThere are {0} values For {1}.", _
environmentKey.ValueCount.ToString(), environmentKey.Name)
For Each valueName As String In environmentKey.GetValueNames()
Console.WriteLine("{0,-20}: {1}", valueName, _
environmentKey.GetValue(valueName).ToString())
Next
' Close the registry key.
environmentKey.Close()
End Sub
End Class
Комментарии
RegistryHive значения используются методом OpenRemoteBaseKey для представления узла верхнего уровня запрошенного ключа на внешнем (удаленном) компьютере. Узел, который можно открыть с помощью метода OpenRemoteBaseKey, должен быть одним из этих верхних уровней RegistryKeys. Дальнейший доступ к вложенным ключам идентифицированного узла доступен с помощью методов RegistryKey, если у пользователя есть соответствующее разрешение.