Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 How to add Registry values in VB?
Index -> Programming, Visual Basic and Other Basics -> Visual Basic Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Ashi_Mashi2




PostPosted: Thu Mar 17, 2005 7:27 pm   Post subject: How to add Registry values in VB?

Hi, I am new to visual basic, and i need to add a registry value to the 'HKEY_LOCAL_USER..." how do you do it? i scanned through many websites, but they were too professional....if you could please explain it very basic to me...thanks...
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Thu Mar 17, 2005 9:34 pm   Post subject: (No subject)

if you're new to a language, you shouldn't be messing with registry values right away. Play with some buttons first, get to know what you're doing.
Brightguy




PostPosted: Fri Mar 18, 2005 8:54 pm   Post subject: Re: How to add Registry values in VB?

Yeah, Tony's right... but if you just want your application to store a few values...
code:
SaveSetting appname, section, key, setting

This will create a string value in HKEY_CURRENT_USER\Software\VB and VBA Program Settings\appname\section. It's more complicated if you want to save somewhere else, or to something other than a string. (Use Win API functions.)
Ashi_Mashi2




PostPosted: Sun Mar 20, 2005 7:19 pm   Post subject: (No subject)

thanks guys....i told you i'm new, but not that new Wink ....lol....anyway, i found a way to do it Very Happy ...I still dont quiet understand what it is doing (cause i got the code from another website) but, it works anyway...

code:

Public Function CreateRegKey(sPath As String, Optional lKey As HKEYS = HKEY_LOCAL_MACHINE) As Long

    Dim hNewKey As Long         'handle to the new key
    Dim lRetVal As Long         'result of the RegCreateKeyEx function
    Dim lRetVal2 As Long         'result of the RegCreateKeyEx function
       
    ' if the path has a leading "\" strip it
    FixPath sPath
    lRetVal = RegCreateKeyEx(lKey, sPath, 0&, vbNullString, REG_OPTION_NON_VOLATILE, _
                                KEY_ALL_ACCESS, 0&, hNewKey, lRetVal2)
    If lRetVal <> ERROR_SUCCESS Then
        lRetVal = lRetVal + ERROR_OFFSET
        CreateRegKey = lRetVal
    Else
        CreateRegKey = 0
        RegCloseKey hNewKey
    End If
End Function
betaflye




PostPosted: Wed Apr 20, 2005 6:28 pm   Post subject: (No subject)

It's basically an API call, if you want more goodies like that just install MSDN library.
Display posts from previous:   
   Index -> Programming, Visual Basic and Other Basics -> Visual Basic Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 5 Posts ]
Jump to:   


Style:  
Search: