Results 1 to 9 of 9

Thread: Checking Registry Values

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2005
    Posts
    300

    Checking Registry Values

    Hi All,

    I need to make an application that reads the value of a registry key.

    I need it to look for the value in the following format
    So i can have it as a function and call it changing the following

    HKEY_LOCAL_MACHINE & Path & Key

    then retuen the value. So i can then check the value against what i am expecting to be returned.

    Hope this is clear.
    Im Learning !!!!

  2. #2
    Just Married shakti5385's Avatar
    Join Date
    Mar 2006
    Location
    Udaipur,Rajasthan(INDIA)
    Posts
    3,747

    Re: Checking Registry Values

    VB Code:
    1. On Error GoTo Err:
    2.     If Len(QueryValue(HKEY_LOCAL_MACHINE, _
    3.     "SOFTWARE\Microsoft\Windows\CurrentVersion\Run", _
    4.     "My Program")) Then
    5.         MsgBox "Value Exists"
    6.        
    7.     Else
    8.         MsgBox "Value Does Not Exist"
    9.        
    10.     End If
    11.     Exit Sub
    12. Err:
    13.     MsgBox "Check Value Error!"
    14.     Exit Sub

  3. #3
    Fanatic Member schoolbusdriver's Avatar
    Join Date
    Jan 2006
    Location
    O'er yonder
    Posts
    1,020

    Re: Checking Registry Values

    The exact format of the code depends on what type of value you are trying to read/write. The possible variations are:-
    VB Code:
    1. 'Registry type constants.
    2. Public Const REG_BINARY = 3                     ' Free form binary
    3. Public Const REG_DWORD = 4                      ' 32-bit number
    4. Public Const REG_DWORD_BIG_ENDIAN = 5           ' 32-bit number
    5. Public Const REG_DWORD_LITTLE_ENDIAN = 4        ' 32-bit number (same as REG_DWORD)
    6. Public Const REG_EXPAND_SZ = 2                  ' Unicode nul terminated string
    7. Public Const REG_LINK = 6                       ' Symbolic Link (unicode)
    8. Public Const REG_MULTI_SZ = 7                   ' Multiple Unicode strings
    9. Public Const REG_NONE = 0                       ' No value type
    10. Public Const REG_RESOURCE_LIST = 8              ' Resource list in the resource map
    11. Public Const REG_SZ = 1                         ' Unicode nul terminated string
    Are you after a particular type ?

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2005
    Posts
    300

    Re: Checking Registry Values

    the entries i am checking are going to return all different types and values. So i just need to navigate to the key take the value from it and then ima just do a simple statement to compare it to what i expect. So i just need something to grab the value.
    Im Learning !!!!

  5. #5
    Just Married shakti5385's Avatar
    Join Date
    Mar 2006
    Location
    Udaipur,Rajasthan(INDIA)
    Posts
    3,747

    Re: Checking Registry Values

    for this u have to add the project in the registry and then u have to check it again....

  6. #6
    Fanatic Member schoolbusdriver's Avatar
    Join Date
    Jan 2006
    Location
    O'er yonder
    Posts
    1,020

    Re: Checking Registry Values

    Check out this site:- skillreactor.org This will get you the most common types. (don't be put off by the site's appearance - the info is accurate) As for navigating to a key via a GUI from your app, you're effectively talking about creating a regedit clone... or have I misunderstood you ?
    Last edited by schoolbusdriver; Aug 13th, 2006 at 02:12 PM.

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2005
    Posts
    300

    Re: Checking Registry Values

    Not i really i dont want to touch the Key at all.

    All i need to do it its return the value from a key specificed. I don't have to navigate to it, can do all that internally i just need to return the value.
    Im Learning !!!!

  8. #8
    Smitten by reality Harsh Gupta's Avatar
    Join Date
    Feb 2005
    Posts
    2,938

    Re: Checking Registry Values

    you will need 3 APIs - RegOpenKey Api (to open a specific key, and dont worry, you are not playing with keys but just reading them), RegQueryValueEx API (to get a value of certain key) and RegCloseKey API (of course, to close the open key).

    check the example on this page of AllAPI.net.

    if you still could not understand, post back. just go through the example carefully, it is a good example to learn.
    Show Appreciation. Rate Posts.

  9. #9
    Fanatic Member schoolbusdriver's Avatar
    Join Date
    Jan 2006
    Location
    O'er yonder
    Posts
    1,020

    Re: Checking Registry Values

    Hmmm... What is your prog going to do exactly? Saying you want to retrieve any sort of value doesn't doesn't help. For instance, a username and password could be encrypted in a UDT and stored as a REG_BINARY value, making it undecipherable to the average Joe. If YOU were to read the value, you wouldn't be able to make sense of it, as you wouldn't know the structure of the UDT or the encryption method. (no insult intended ) The most you could do would be to check for its existence.

    So it's back to square one... what type of key do you want to check ? If you only want to check existing keys, take a look at them with the registry editor to find out their type - REG_SZ etc. (I have 'stock' routines for most types)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width