Hey guys,
VB .NET does appear to be much easier to access and modify the registry, but I am stuck on one problem. I can access the regisrty, create a new key, and assign a value. However, I can only do this if the folder already exist. How do I create a new folder?
For example, the below code will run with no errors, but upon checking the registry a key has not been added. If I change 'MyProgram' in the .CreateSubKey line to a folder that already exist in the the registry, then a key is made under that folder with the proper value. So how do I force the code to make a folder if it does not exist?
Thanks,
/Tril
Imports Microsoft.Win32 ‘Namespace Required for Accessing Registry
Public Sub WriteToRegistry
Dim regKey As RegistryKey, regSubKey As RegistryKey
‘regKey now points to HKEYCURRENTUSER Registry Key
regKey = Registry.CurrentUser
‘A Sub key called MyProgram is created under the HKEYCURRENTUSER key
regSubKey =regKey.CreateSubKey ("MyProgram")
‘The value of the Key is set to VeryGoodSetting
regSubKey.SetValue ("MyValue", "VeryGoodSetting")
End Sub
Enter your message below
Sign in or Join us (it's free).