forked from PowerShell/PowerShell
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTransactedRegistry.cs
More file actions
134 lines (125 loc) · 7.08 KB
/
Copy pathTransactedRegistry.cs
File metadata and controls
134 lines (125 loc) · 7.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
// ==++==
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ==--==
//
// NOTE: A vast majority of this code was copied from BCL in
// ndp\clr\src\BCL\Microsoft\Win32\Registry.cs.
// Namespace: Microsoft.Win32
//
using BCLDebug = System.Diagnostics.Debug;
namespace Microsoft.PowerShell.Commands.Internal
{
using System;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using Microsoft.Win32;
using System.Management.Automation;
using System.Diagnostics.CodeAnalysis;
using System.Transactions;
/**
* Registry encapsulation. Contains members representing all top level system
* keys.
*
* @security(checkClassLinking=on)
*/
//This class contains only static members and does not need to be serializable.
[ComVisible(true)]
// Suppressed because these objects need to be accessed from CmdLets.
[SuppressMessage("Microsoft.MSInternal", "CA903:InternalNamespaceShouldNotContainPublicTypes")]
internal static class TransactedRegistry
{
private const string resBaseName = "RegistryProviderStrings";
/**
* Current User Key.
*
* This key should be used as the root for all user specific settings.
*/
/// <summary>TransactedRegistry.CurrentUser
/// <para>This static method returns a TransactedRegistryKey object that represents the base
/// key HKEY_CURRENT_USER. Because it is a base key, there is no transaction associated with
/// the returned TransactedRegistryKey. This means that values modified using the returned
/// TransactedRegistryKey are NOT modified within a transaction.</para>
/// <para>However, if the returned TransactedRegistryKey is used to create, open, or delete
/// subkeys, there must be a Transaction.Current and the resulting TransactedRegistryKey from those operations ARE associated with
/// the transaction.</para>
/// </summary>
[ResourceExposure(ResourceScope.Machine)]
// The TransactedRegistryKey's members cannot be changed.
[SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")]
internal static readonly TransactedRegistryKey CurrentUser = TransactedRegistryKey.GetBaseKey(BaseRegistryKeys.HKEY_CURRENT_USER);
/**
* Local Machine Key.
*
* This key should be used as the root for all machine specific settings.
*/
/// <summary>TransactedRegistry.LocalMachine
/// <para>This static method returns a TransactedRegistryKey object that represents the base
/// key HKEY_LOCAL_MACHINE. Because it is a base key, there is no transaction associated with
/// the returned TransactedRegistryKey. This means that values modified using the returned
/// TransactedRegistryKey are NOT modified within a transaction.</para>
/// <para>However, if the returned TransactedRegistryKey is used to create, open, or delete
/// subkeys, there must be a Transaction.Current and the resulting TransactedRegistryKey from those operations ARE associated with
/// the transaction.</para>
/// </summary>
[ResourceExposure(ResourceScope.Machine)]
// The TransactedRegistryKey's members cannot be changed.
[SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")]
internal static readonly TransactedRegistryKey LocalMachine = TransactedRegistryKey.GetBaseKey(BaseRegistryKeys.HKEY_LOCAL_MACHINE);
/**
* Classes Root Key.
*
* This is the root key of class information.
*/
/// <summary>TransactedRegistry.ClassesRoot
/// <para>This static method returns a TransactedRegistryKey object that represents the base
/// key HKEY_CLASSES_ROOT. Because it is a base key, there is no transaction associated with
/// the returned TransactedRegistryKey. This means that values modified using the returned
/// TransactedRegistryKey are NOT modified within a transaction.</para>
/// <para>However, if the returned TransactedRegistryKey is used to create, open, or delete
/// subkeys, there must be a Transaction.Current and the resulting TransactedRegistryKey from those operations ARE associated with
/// the transaction.</para>
/// </summary>
[ResourceExposure(ResourceScope.Machine)]
// The TransactedRegistryKey's members cannot be changed.
[SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")]
internal static readonly TransactedRegistryKey ClassesRoot = TransactedRegistryKey.GetBaseKey(BaseRegistryKeys.HKEY_CLASSES_ROOT);
/**
* Users Root Key.
*
* This is the root of users.
*/
/// <summary>TransactedRegistry.Users
/// <para>This static method returns a TransactedRegistryKey object that represents the base
/// key HKEY_USERS. Because it is a base key, there is no transaction associated with
/// the returned TransactedRegistryKey. This means that values modified using the returned
/// TransactedRegistryKey are NOT modified within a transaction.</para>
/// <para>However, if the returned TransactedRegistryKey is used to create, open, or delete
/// subkeys, there must be a Transaction.Current and the resulting TransactedRegistryKey from those operations ARE associated with
/// the transaction.</para>
/// </summary>
[ResourceExposure(ResourceScope.Machine)]
// The TransactedRegistryKey's members cannot be changed.
[SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")]
internal static readonly TransactedRegistryKey Users = TransactedRegistryKey.GetBaseKey(BaseRegistryKeys.HKEY_USERS);
/**
* Current Config Root Key.
*
* This is where current configuration information is stored.
*/
/// <summary>TransactedRegistry.CurrentConfig
/// <para>This static method returns a TransactedRegistryKey object that represents the base
/// key HKEY_CURRENT_CONFIG. Because it is a base key, there is no transaction associated with
/// the returned TransactedRegistryKey. This means that values modified using the returned
/// TransactedRegistryKey are NOT modified within a transaction.</para>
/// <para>However, if the returned TransactedRegistryKey is used to create, open, or delete
/// subkeys, there must be a Transaction.Current and the resulting TransactedRegistryKey from those operations ARE associated with
/// the transaction.</para>
/// </summary>
[ResourceExposure(ResourceScope.Machine)]
// The TransactedRegistryKey's members cannot be changed.
[SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")]
internal static readonly TransactedRegistryKey CurrentConfig = TransactedRegistryKey.GetBaseKey(BaseRegistryKeys.HKEY_CURRENT_CONFIG);
}
}