# HELP! Registry Functions in C#.NET

**URL:** <https://forums.thehomestack.io/t/help-registry-functions-in-c-net/117>\
**Category:** vb.Net\
**Created:** [January 3, 2004, 2:01am UTC](https://forums.thehomestack.io/t/help-registry-functions-in-c-net/117 "2004-01-03T02:01:55Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![robinhood1995](https://forums.thehomestack.io/letter_avatar_proxy/v4/letter/r/48db29/32.png) [@robinhood1995](https://forums.thehomestack.io/u/robinhood1995)\
**Post date:** [January 3, 2004, 2:01am UTC](https://forums.thehomestack.io/t/help-registry-functions-in-c-net/117/1 "2004-01-03T02:01:55Z")

</div>

```auto

// C# 
Microsoft.Win32.RegistryKey REGKEY; 
string sVal; 

REGKEY = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("PathofKey"); 
//open a string value from the registry 
sVal = (string) REGKEY.GetValue("NameOfValue",(object)"DefaultReturn");

```

To change registry values:

```auto

// C# 

Object oVal; 
Microsoft.Win32.RegistryKey REGKEY; 
oVal = "NewValue"; 
//the true on the end of the call makes the registry entry writable 
REGKEY = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("KeyToOpen",true); 
REGKEY.SetValue("NewValName",oVal);

```
