Skip to content

Add registry key creation documentation with permissions guidance #47686

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Jul 31, 2025

This PR adds comprehensive documentation for creating registry keys in C# with important guidance on permissions and security considerations.

Problem Addressed

Users reported that registry code examples only work when running Visual Studio as administrator, and requested documentation about permissions and whether applications can routinely store/update registry values at runtime.

Changes Made

New Documentation Structure

  • Created /docs/csharp/programming-guide/file-system/ directory
  • Added how-to-create-a-key-in-the-registry.md with comprehensive guidance
  • Added section overview page (index.md)
  • Updated C# programming guide table of contents

Key Content Added

Permissions Guidance:

  • Clear explanation that HKEY_CURRENT_USER doesn't require administrator privileges
  • Table showing permission requirements for different registry hives
  • Best practices for production applications

Code Examples:

  • Basic registry key creation using HKEY_CURRENT_USER (no admin required)
  • Robust error handling for access denied scenarios
  • Demonstration of permission differences between user and system registry access
  • Windows platform attributes for cross-platform compatibility

Security and Best Practices:

  • When to use user-specific vs system-wide storage
  • How to handle permission failures gracefully
  • Security considerations for data validation and storage
  • Alternatives to registry for application configuration

Example Usage

The documentation now shows how to create registry keys without requiring administrator privileges:

// This works without administrator privileges
RegistryKey key = Registry.CurrentUser.CreateSubKey("TestApp");
key.SetValue("LastRun", DateTime.Now);
key.Close();

And includes proper error handling for scenarios where permissions are insufficient.

Fixes #30779.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.


Internal previews

📄 File 🔗 Preview link
docs/csharp/programming-guide/file-system/how-to-create-a-key-in-the-registry.md docs/csharp/programming-guide/file-system/how-to-create-a-key-in-the-registry
docs/csharp/programming-guide/file-system/index.md docs/csharp/programming-guide/file-system/index
docs/csharp/toc.yml docs/csharp/toc

@dotnet-policy-service dotnet-policy-service bot added the okr-quality Content-quality KR: Concerns article defects (bugs), freshness, or build warnings. label Jul 31, 2025
@Copilot Copilot AI changed the title [WIP] Need some words on registry permissions Add registry key creation documentation with permissions guidance Jul 31, 2025
@Copilot Copilot AI requested a review from BillWagner July 31, 2025 16:21
Copilot finished work on behalf of BillWagner July 31, 2025 16:21
@BillWagner
Copy link
Member

closing this

@BillWagner BillWagner closed this Aug 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dotnet-csharp/svc fundamentals/subsvc okr-quality Content-quality KR: Concerns article defects (bugs), freshness, or build warnings.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Need some words on registry permissions
2 participants