Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi Guys,
can someone please help me with this scenario.

I want to query the data in the registry.The value in the registry key is random.I tried using RegQueryValueEx(),In that i have to declare the value (2nd parameter). but in my case value for the key is random.

Can someone help me to query the data in the registry.


Regards
Ron
Posted
Comments
Sergey Alexandrovich Kryukov 28-May-12 13:55pm    
What do you mean "key is random"? If it is totally random, isn't that obvious that it will be a non-existing key, with overwhelming probability? Why doing all that?
--SA

Start here[^], then take a look at the following example, which demonstrates how to retrieve the subkeys of this key, and prints their names to the screen:
[Visual Basic]
VB
Imports System
Imports Microsoft.Win32

Class Reg
    
    Public Shared Sub Main()
        
        ' Create a RegistryKey, which will access the HKEY_USERS
        ' key in the registry of this machine.
        Dim rk As RegistryKey = Registry.Users
        
        ' Print out the keys.
        PrintKeys(rk)
    End Sub    
    
    Shared Sub PrintKeys(rkey As RegistryKey)
        
        ' Retrieve all the subkeys for the specified key.
        Dim names As String() = rkey.GetSubKeyNames()
        
        Dim icount As Integer = 0
        
        Console.WriteLine("Subkeys of " & rkey.Name)
        Console.WriteLine("-----------------------------------------------")
        
        ' Print the contents of the array to the console.
        Dim s As String
        For Each s In  names
            Console.WriteLine(s)
            
            ' The following code puts a limit on the number
            ' of keys displayed.  Comment it out to print the
            ' complete list.
            icount += 1            
            If icount >= 10 Then
                Exit For
            End If
        Next s
    End Sub
End Class

source: http://msdn.microsoft.com/en-us/library/microsoft.win32.registry%28v=vs.71%29.aspx[^]

I hope it will be helpful.
 
Share this answer
 
Comments
Sandeep Mewara 31-May-12 1:40am    
5. good effort.
Maciej Los 31-May-12 1:48am    
Thank you, Sandeep ;)
You want RegEnumValue()[^].
 
Share this answer
 
Comments
Maciej Los 30-May-12 18:38pm    
It could be the correct answer ;)
+5!
Richard MacCutchan 30-May-12 19:02pm    
It could, but the question is not very clear.
Maciej Los 31-May-12 1:48am    
I agree with you ;)
Have a nice day!

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