You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
description: Learn how to create registry keys in C#, including important permissions considerations and security requirements for registry access.
4
+
ms.date: 01/16/2025
5
+
helpviewer_keywords:
6
+
- "registry keys [C#]"
7
+
- "registries [C#], creating keys"
8
+
- "permissions [C#], registry"
9
+
- "Windows Registry [C#]"
10
+
ms.topic: how-to
11
+
---
12
+
# How to create a key in the registry (C# Programming Guide)
13
+
14
+
This example creates a key in the current user's registry and stores a value in it. This example demonstrates how to work with the Windows Registry using C#, including important considerations about permissions and security.
15
+
16
+
## Prerequisites and Permissions
17
+
18
+
Before working with the Windows Registry, it's important to understand the permission requirements:
19
+
20
+
-**Administrator privileges**: Some registry operations require elevated permissions. Writing to `HKEY_LOCAL_MACHINE` or other system-wide registry hives typically requires administrator privileges.
21
+
-**User-specific access**: Writing to `HKEY_CURRENT_USER` generally doesn't require administrator privileges and is the recommended approach for application settings.
22
+
-**Production considerations**: Applications should be designed to work without requiring administrator privileges for routine operations.
23
+
24
+
## Example
25
+
26
+
The following example creates a key under `HKEY_CURRENT_USER`, which is accessible without administrator privileges:
0 commit comments