How do I get a key's data using API's only? Thanks. (No WScript please)
Printable View
How do I get a key's data using API's only? Thanks. (No WScript please)
Check the link in my sig
Keys cant contain data. Only values can.
Or do you mean that you want to enumerate (list) all the values in a certain key?
I meant the values sorry.
Is there any other code I can use, because that one doesn't look like its using API.
Heres all the code in a module.
The link in my sig fully uses API :rolleyes:
Oh I see how it works now, but how can I check if a key exists? I'm using the read function but I am confused, can you give me an example?
Sure bro,
VB Code:
Private Function KeyExists(Hkey As String, Section As String, Valuekey As String) As Boolean On Error Resume Next Set Reg = New cRegistry Reg.ClassKey = Hkey Reg.SectionKey = Section Reg.Valuekey = Valuekey If Reg.Value <> Empty Then KeyExists = True End Function
Remix, seems to be a problem with the ShellAndFind(Hwnd) Link in your sig?
It should be:
http://www.vbforums.com/showthread.p...61#post2214161
I've Done this:
VB Code:
Call KeyExists(HKEY_LOCAL_MACHINE, "SOFTWARE\Mozilla\Mozilla Firefox 1.5\bin", "PathToExe")
Should I do this instead:
VB Code:
If KeyExists(HKEY_LOCAL_MACHINE, "SOFTWARE\Mozilla\Mozilla Firefox 1.5\bin", "PathToExe") Then 'Do Stuff End If
Oh, and how can I read the value using the read thing? And save it to a string variable?
Sorry, I meant to provide an explanation :blush:
VB Code:
Option Explicit Dim reg As cRegistry Private Sub Form_Load() If KeyExists(HKEY_CURRENT_USER, "SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings", "ProxyServer") = True Then 'Key exists End If Dim tReg As String tReg = ReadReg(HKEY_CURRENT_USER, "SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings", "ProxyServer") End Sub Private Function KeyExists(Hkey As String, Section As String, Valuekey As String) As Boolean On Error Resume Next Set reg = New cRegistry reg.ClassKey = Hkey reg.SectionKey = Section reg.Valuekey = Valuekey If reg.Value <> Empty Then KeyExists = True End Function Private Function ReadReg(Hkey As String, Section As String, Valuekey As String) As String Set reg = New cRegistry reg.ClassKey = Hkey reg.SectionKey = Section reg.Valuekey = Valuekey ReadReg = reg.Value End Function
I think that should do it :wave:
Thanks :wave:Quote:
Originally Posted by jcis
Thanks for the help.