Results 1 to 14 of 14

Thread: [RESOLVED] Registry Read with API only?

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2005
    Posts
    546

    Resolved [RESOLVED] Registry Read with API only?

    How do I get a key's data using API's only? Thanks. (No WScript please)
    Did you find a post in this thread useful? Please click Rate This Post.

  2. #2
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: Registry Read with API only?

    Check the link in my sig

  3. #3
    Next Of Kin baja_yu's Avatar
    Join Date
    Aug 2002
    Location
    /dev/root
    Posts
    5,989

    Re: Registry Read with API only?

    Keys cant contain data. Only values can.

    Or do you mean that you want to enumerate (list) all the values in a certain key?

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2005
    Posts
    546

    Re: Registry Read with API only?

    I meant the values sorry.
    Did you find a post in this thread useful? Please click Rate This Post.

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2005
    Posts
    546

    Re: Registry Read with API only?

    Is there any other code I can use, because that one doesn't look like its using API.
    Did you find a post in this thread useful? Please click Rate This Post.

  6. #6
    Next Of Kin baja_yu's Avatar
    Join Date
    Aug 2002
    Location
    /dev/root
    Posts
    5,989

    Re: Registry Read with API only?

    Heres all the code in a module.
    Attached Files Attached Files

  7. #7
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: Registry Read with API only?

    The link in my sig fully uses API

  8. #8

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2005
    Posts
    546

    Re: Registry Read with API only?

    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?
    Did you find a post in this thread useful? Please click Rate This Post.

  9. #9
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: Registry Read with API only?

    Sure bro,

    VB Code:
    1. Private Function KeyExists(Hkey As String, Section As String, Valuekey As String) As Boolean
    2.     On Error Resume Next
    3.     Set Reg = New cRegistry
    4.     Reg.ClassKey = Hkey
    5.     Reg.SectionKey = Section
    6.     Reg.Valuekey = Valuekey
    7.     If Reg.Value <> Empty Then KeyExists = True
    8. End Function

  10. #10
    PowerPoster jcis's Avatar
    Join Date
    Jan 2003
    Location
    Argentina
    Posts
    4,430

    Re: Registry Read with API only?

    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
    Last edited by jcis; Feb 27th, 2006 at 10:55 PM.

  11. #11

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2005
    Posts
    546

    Re: Registry Read with API only?

    I've Done this:

    VB Code:
    1. Call KeyExists(HKEY_LOCAL_MACHINE, "SOFTWARE\Mozilla\Mozilla Firefox 1.5\bin", "PathToExe")

    Should I do this instead:

    VB Code:
    1. If KeyExists(HKEY_LOCAL_MACHINE, "SOFTWARE\Mozilla\Mozilla Firefox 1.5\bin", "PathToExe") Then
    2. 'Do Stuff
    3. End If

    Oh, and how can I read the value using the read thing? And save it to a string variable?
    Did you find a post in this thread useful? Please click Rate This Post.

  12. #12
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: Registry Read with API only?

    Sorry, I meant to provide an explanation

    VB Code:
    1. Option Explicit
    2.  
    3. Dim reg As cRegistry
    4.  
    5. Private Sub Form_Load()
    6.     If KeyExists(HKEY_CURRENT_USER, "SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings", "ProxyServer") = True Then
    7.         'Key exists
    8.     End If
    9.     Dim tReg As String
    10.     tReg = ReadReg(HKEY_CURRENT_USER, "SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings", "ProxyServer")
    11. End Sub
    12.  
    13. Private Function KeyExists(Hkey As String, Section As String, Valuekey As String) As Boolean
    14.     On Error Resume Next
    15.     Set reg = New cRegistry
    16.     reg.ClassKey = Hkey
    17.     reg.SectionKey = Section
    18.     reg.Valuekey = Valuekey
    19.     If reg.Value <> Empty Then KeyExists = True
    20. End Function
    21.  
    22. Private Function ReadReg(Hkey As String, Section As String, Valuekey As String) As String
    23.     Set reg = New cRegistry
    24.     reg.ClassKey = Hkey
    25.     reg.SectionKey = Section
    26.     reg.Valuekey = Valuekey
    27.     ReadReg = reg.Value
    28. End Function

    I think that should do it

  13. #13
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: Registry Read with API only?

    Quote Originally Posted by jcis
    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
    Thanks

  14. #14

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2005
    Posts
    546

    Re: Registry Read with API only?

    Thanks for the help.
    Did you find a post in this thread useful? Please click Rate This Post.

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