|
-
Aug 11th, 2006, 03:49 AM
#1
Thread Starter
Hyperactive Member
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.
-
Aug 11th, 2006, 03:55 AM
#2
Re: Checking Registry Values
VB Code:
On Error GoTo Err:
If Len(QueryValue(HKEY_LOCAL_MACHINE, _
"SOFTWARE\Microsoft\Windows\CurrentVersion\Run", _
"My Program")) Then
MsgBox "Value Exists"
Else
MsgBox "Value Does Not Exist"
End If
Exit Sub
Err:
MsgBox "Check Value Error!"
Exit Sub
-
Aug 11th, 2006, 04:09 AM
#3
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:
'Registry type constants.
Public Const REG_BINARY = 3 ' Free form binary
Public Const REG_DWORD = 4 ' 32-bit number
Public Const REG_DWORD_BIG_ENDIAN = 5 ' 32-bit number
Public Const REG_DWORD_LITTLE_ENDIAN = 4 ' 32-bit number (same as REG_DWORD)
Public Const REG_EXPAND_SZ = 2 ' Unicode nul terminated string
Public Const REG_LINK = 6 ' Symbolic Link (unicode)
Public Const REG_MULTI_SZ = 7 ' Multiple Unicode strings
Public Const REG_NONE = 0 ' No value type
Public Const REG_RESOURCE_LIST = 8 ' Resource list in the resource map
Public Const REG_SZ = 1 ' Unicode nul terminated string
Are you after a particular type ?
-
Aug 13th, 2006, 10:53 AM
#4
Thread Starter
Hyperactive Member
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.
-
Aug 13th, 2006, 11:12 AM
#5
Re: Checking Registry Values
for this u have to add the project in the registry and then u have to check it again....
-
Aug 13th, 2006, 02:08 PM
#6
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.
-
Aug 13th, 2006, 05:07 PM
#7
Thread Starter
Hyperactive Member
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.
-
Aug 13th, 2006, 05:18 PM
#8
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.
-
Aug 14th, 2006, 03:41 AM
#9
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|