Results 1 to 11 of 11

Thread: Get rigistry value from outsite of VB and VBA Programing

  1. #1

    Thread Starter
    Hyperactive Member dandono's Avatar
    Join Date
    Aug 2004
    Location
    Cornwall, UK
    Posts
    485

    Get rigistry value from outsite of VB and VBA Programing

    hi, i am trying to get and change a string from outsite HKEY_CURRENT_USER\Software\VB and VBA Programming\
    as in somewhere like HKEY_USERS\.DEFAULT\Controll Pannel\Desktop\ or somewhere. i know of getsetting and savesetting but i can not get them to work with anything outsite of the VB and VBA Programming Key. What can i use the get and change a string value from outside of VB and VBA Prog.. Key?
    thanks, dandono.
    If there is only one perfect person in the universe, does that make them imperfect?

  2. #2
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Get rigistry value from outsite of VB and VBA Programing

    I think this is a FAQ submission candidate (unless it exists... did you check? )

    Do a forum search for "registry" and you will find umpteen examples

  3. #3

    Thread Starter
    Hyperactive Member dandono's Avatar
    Join Date
    Aug 2004
    Location
    Cornwall, UK
    Posts
    485

    Re: Get rigistry value from outsite of VB and VBA Programing

    i found umpteen examples of the GetSetting and SaveSetting method that does not do anything outside of VB and VBA Prog.. Key. I found this thread
    Quote Originally Posted by Joacim Andersson
    Yes you can get it to save your settings under any key in the registry but not without using the registry API functions. The GetSetting and SaveSetting functions only work on the above mentioned key.
    so i guess i need to search for the registry API now
    ps: i did do a forum search but only searched a few pages
    If there is only one perfect person in the universe, does that make them imperfect?

  4. #4
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Get rigistry value from outsite of VB and VBA Programing

    If only you'd searched the Codebank forum, you'd have found these on the first page:

    http://www.vbforums.com/showthread.php?t=344540
    http://www.vbforums.com/showthread.php?t=231560

  5. #5

    Thread Starter
    Hyperactive Member dandono's Avatar
    Join Date
    Aug 2004
    Location
    Cornwall, UK
    Posts
    485

    Re: Get rigistry value from outsite of VB and VBA Programing

    VB Code:
    1. Option Explicit
    2. Dim reg As cRegistry
    3.  
    4. Private Sub SaveSettings() 'Writes to Registry
    5.     Set reg = New cRegistry
    6.     'This will create a new value in the Run section
    7.     'so your program will automatically run when Windows starts
    8.        'This will create a new section to store your own keys in
    9.     reg.ClassKey = HKEY_USERS
    10.     reg.SectionKey = ".DEFAULT\Control Panel\Desktop"
    11.     reg.ValueKey = "Wallpaper"
    12.     reg.ValueType = REG_SZ
    13.     reg.Value = CLng(Text2.Text)
    14. End Sub
    15.  
    16. Private Sub GetSettings() 'Reads the Registry
    17.     Set reg = New cRegistry
    18.     reg.ClassKey = HKEY_USERS
    19.     reg.SectionKey = ".DEFAULT\Control Panel\Desktop"
    20.     reg.ValueKey = "Wallpaper"
    21. End Sub
    22.  
    23. Private Sub Form_Load()
    24. Call GetSettings
    25. Text1.Text = reg.Value
    26. End Sub
    27.  
    28. Private Sub Form_Unload(Cancel As Integer)
    29. SaveSettings
    30. End Sub

    vbruntime error 13
    If there is only one perfect person in the universe, does that make them imperfect?

  6. #6
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Get rigistry value from outsite of VB and VBA Programing

    That's not very helpful, where does the error occur.

  7. #7

    Thread Starter
    Hyperactive Member dandono's Avatar
    Join Date
    Aug 2004
    Location
    Cornwall, UK
    Posts
    485

    Re: Get rigistry value from outsite of VB and VBA Programing

    at unload
    If there is only one perfect person in the universe, does that make them imperfect?

  8. #8
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Get rigistry value from outsite of VB and VBA Programing

    What exact line does it break upon, and what is highlighted?

  9. #9

    Thread Starter
    Hyperactive Member dandono's Avatar
    Join Date
    Aug 2004
    Location
    Cornwall, UK
    Posts
    485

    Re: Get rigistry value from outsite of VB and VBA Programing

    the line with
    VB Code:
    1. reg.Value = CLng(Text2.Text)
    in the SaveSettings function
    If there is only one perfect person in the universe, does that make them imperfect?

  10. #10
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Get rigistry value from outsite of VB and VBA Programing

    Don't use CLng(). If the key type is REG_SZ it means a string, and you're trying to convert it to a Long instead.

  11. #11

    Thread Starter
    Hyperactive Member dandono's Avatar
    Join Date
    Aug 2004
    Location
    Cornwall, UK
    Posts
    485

    Re: Get rigistry value from outsite of VB and VBA Programing

    It works now, thanks.
    If there is only one perfect person in the universe, does that make them imperfect?

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