Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

working with registry using vb.net

Status
Not open for further replies.

minus0

Programmer
Feb 20, 2003
73
US
Hello all,

I wrote a couple procedures to go through the registry to search for a keyword but its failing midway through saying "Requested registry access is not allowed". I am running as a user with admin privileges and opened the registry as read/write, so what am i missing here?

Code:
Private Sub GetSubKeys(ByVal SubKey As RegistryKey) 
    Dim SearchWord As String 
    SearchWord = "SYMANTEC" 
    For Each innerKey As String In SubKey.GetSubKeyNames 
      Dim local As RegistryKey = Registry.LocalMachine 
' == line below is where it breaks ==    
  local = SubKey.OpenSubKey(innerKey, True) 
      If InStr(local.ToString.ToUpper, SearchWord) Then 
        sw.Write(local.ToString + Chr(13) + Chr(10)) 
        Exit For 
      End If 
      GetSubKeys(local) 
    Next 
   End Sub 

  Private Sub btnGetKeysDemo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGetKeysDemo.Click 
    Dim WhichRegKey As RegistryKey = Registry.LocalMachine 
    WhichRegKey = WhichRegKey.OpenSubKey("software", True) 
    GetSubKeys(WhichRegKey) 
    MsgBox("done") 
  End Sub

Thanks in advance
-0
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top