Click here to Skip to main content
15,892,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

Using this code which I found on this web site to try to create a registry key to store an ID tag from my program:
VB
Imports Microsoft.Win32

Public Class Form1
    Dim regKey As RegistryKey
 'Makes the key  
 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        regKey = Registry.LocalMachine.OpenSubKey("Software", True)  
        regKey.CreateSubKey("MyAppV2")
        regKey.Close()
    End Sub

'Delete the key
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        
        regKey = Registry.LocalMachine.OpenSubKey("Software", True)  
        regKey.DeleteSubKey("MyAppV", True)
        regKey.Close()
    End Sub

'Read/write from key:
    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Dim ver As Decimal
        regKey = Registry.LocalMachine.OpenSubKey("Software\MyAppV", True) 
        ' regKey.SetValue("AppName", "MyRegApp")
        ver = regKey.GetValue("Version", 0.0)
        If ver < 1.1 Then regKey.SetValue("Version", 1.1)
        regKey.Close()
    End Sub
End Class

But when the program runs (any of the 3 buttons) I get an error message "When deploying an Office solution, check to make sure that you have fulfilled all security requirements"
The vb project is set as a "Full trust application". The program is running in Vista.

Any thoughts on what I might be doing wrong or missing?

THANKS
Gary V
Posted
Updated 11-Sep-10 9:05am
v2

You might have to change the UAC settings in Vista to allow this program to access the registry.

See here[^].
 
Share this answer
 
Thanks for the thought...
I gave that a try..clicked on the full access option for myself as a user...but still receive the same error message when I run the code...Registry Access Denied. Amazingly I can access the registry just fine with my VB6 code!
Thanks again!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900