Results 1 to 15 of 15

Thread: What is the registry for?

  1. #1

    Thread Starter
    Hyperactive Member nickwrs's Avatar
    Join Date
    Jan 2000
    Location
    Atlanta, Ga
    Posts
    398
    I know this sounds like a really novice question, but I really don't know the function of the windows registry.

    Is this something I should be using in my applications?

    Thanks for any direction.

    Nick

  2. #2
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    It's the place where applications save different settings. For example when you set the homepage of IE to a specific site it stores it in the registry and when needed it retrieves it.
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  3. #3
    PowerPoster MidgetsBro's Avatar
    Join Date
    Oct 2000
    Location
    Apparently, Internet.com
    Posts
    3,125
    The registry is a place to save short clippings of information. It takes the place of having ini files. If you have stuff, like registration information that you want to save, you can use the registry. If you want to save the size of the window for your app, you can save that in the registry. You can save default colors for you app. The registry pretty much lets you save anything you need to save for your app. There are a few basic statements built into VB. I think it's only in VB5 and VB6 but I'm not sure. The SaveSetting and the GetSetting statements allow you to save settings.
    <removed by admin>

  4. #4

    Thread Starter
    Hyperactive Member nickwrs's Avatar
    Join Date
    Jan 2000
    Location
    Atlanta, Ga
    Posts
    398
    So, do you guys think you should use an ini file or the registry?

    I have always used an ini file.

    But I am always wanting to make my apps a little more professional.

  5. #5
    PowerPoster MidgetsBro's Avatar
    Join Date
    Oct 2000
    Location
    Apparently, Internet.com
    Posts
    3,125
    I think the registry is the way to go, mostly because I haven't figured out the ini files. The registry is more proffessional, because it doesn't allow the causal user to tamper with the settings.
    <removed by admin>

  6. #6
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    The registry stores pretty much everything about the system. All your registered fonts, ActiveX controls, COM objects, Outlook Express email addresses, the lot.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  7. #7
    Lively Member
    Join Date
    May 2005
    Posts
    125

    Re: What is the registry for?

    I'm still a bit confused on how to read and write to the registry. Ive looked over the API's and some examples but I still couldnt understand how to modify it to my needs, giving it the information on weather the user has registered they're program or not.

    All I need is to write a value to a specific key when the user first runs the program (deeming the program as unregistered) and then when the user does register a different value will be set on that key so the next time it will read that value and if the value deeming the program as registered is there i could go from there.

    It seems like it would be easy, I just havent had any experience with the registry API's before.

    all advice is much appreciated.
    --- Science does not explain why things are what they are. What we get from Science is our interpretation of how things do what they do.
    --- No Scientific law of the universe is stable, we did not create it, and we will never understand all of its abilities.
    --- What we determine as reality is a mere assumption of what tomorrow will be based on what yesterday was.

  8. #8
    Lively Member
    Join Date
    May 2005
    Posts
    125

    Re: What is the registry for?

    I coded a simple way to do this with an .ini file, but ini files are too easy to find and modify by the user. Here is what I came up with:

    VB Code:
    1. Private Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal_
    2. lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String,_
    3. ByVal nSize As Long, ByVal lpFileName As String)As Long Private Declare Function WritePrivateProfileString Lib "kernel32"_
    4. Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As Any,_
    5. ByVal lpFileName As String) As Long
    6.  
    7. Private Sub Command1_Click()
    8.  If Text1.Text = "1337" Then
    9.   WritePrivateProfileString App.Title, "KeyName", "Registered", "c:\test.ini"
    10.     'Create a buffer
    11.     Ret = String(255, 0)
    12.     'Retrieve the string
    13.     NC = GetPrivateProfileString(App.Title, "KeyName", "Default", Ret, 255, "C:\test.ini")
    14.     'NC is the number of characters copied to the buffer
    15.     If NC = 10 Then registered = True
    16.  End If
    17.  If registered = True Then Form1.Caption = "Registered!!"
    18. End Sub
    19.  
    20. Private Sub Command2_Click()
    21.  Unload Me
    22. End Sub
    23.  
    24. Private Sub Form_Load()
    25.     Dim Ret As String, NC As Long
    26.     'Create a buffer
    27.     Ret = String(255, 0)
    28.     'Retrieve the string
    29.     NC = GetPrivateProfileString(App.Title, "KeyName", "Default", Ret, 255, "C:\test.ini")
    30.     'NC is the number of characters copied to the buffer
    31.     If NC = 0 Then
    32.         'Write the setting to the file (c:\test.ini) under
    33.     '   Project1 -> Keyname
    34.     WritePrivateProfileString App.Title, "KeyName", "UnRegistered", "c:\test.ini"
    35.     End If
    36.     If NC = 12 Then registered = False
    37.     If registered = False Then Form1.Caption = "UnRegistered!"
    38.     If NC = 10 Then registered = True
    39.     If registered = True Then Form1.Caption = "Registered!!"
    40. End Sub

    Two reasons I dont want to use this..1. unless I learn how to encrypt what is entered into the file (which would be "registered" or "unregistered") any user who finds the file can easily modify it to what they need. Another reason i dont want to use an ini is, I just merely dissassembled my own program and its by far clear to the eye where the ini file is located..so I couldnt hide it.
    Last edited by Resilience; Jun 26th, 2005 at 05:07 PM.
    --- Science does not explain why things are what they are. What we get from Science is our interpretation of how things do what they do.
    --- No Scientific law of the universe is stable, we did not create it, and we will never understand all of its abilities.
    --- What we determine as reality is a mere assumption of what tomorrow will be based on what yesterday was.

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

    Re: What is the registry for?

    You shouldnt 'hijack' someone elses thread. If you have a question, start a new thread.

    Anyway, a search would give you the results you need:

    http://www.vbforums.com/showthread.p...SetStringValue

  10. #10
    Lively Member
    Join Date
    May 2005
    Posts
    125

    Re: What is the registry for?

    lol hijack, dont take it too seriously. They asked a completely general question about the registry so i figured why waste space when i can ask about the registry here too..

    As i said, i had already looked at other examples that i found thru my searches..but I couldnt modify any of them to my needs so I was hopeing it wouldnt be too much of a problem for someone to create one.

    Also, that link you gave me goes to a topic that is of no help..They link to another site "www.vbworld.com/registry" but that gives me a "file not found" error.
    --- Science does not explain why things are what they are. What we get from Science is our interpretation of how things do what they do.
    --- No Scientific law of the universe is stable, we did not create it, and we will never understand all of its abilities.
    --- What we determine as reality is a mere assumption of what tomorrow will be based on what yesterday was.

  11. #11
    Supreme User Madboy's Avatar
    Join Date
    Oct 2003
    Location
    England
    Posts
    3,253

    Re: What is the registry for?

    Quote Originally Posted by Resilience
    VB Code:
    1. Private Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal_
    2. lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String,_
    3. ByVal nSize As Long, ByVal lpFileName As String)As Long Private Declare Function WritePrivateProfileString Lib "kernel32"_
    4. Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As Any,_
    5. ByVal lpFileName As String) As Long
    6.  
    7. Private Sub Command1_Click()
    8.  If Text1.Text = "1337" Then
    9.   WritePrivateProfileString App.Title, "KeyName", "Registered", "c:\test.ini"
    10.     'Create a buffer
    11.     Ret = String(255, 0)
    12.     'Retrieve the string
    13.     NC = GetPrivateProfileString(App.Title, "KeyName", "Default", Ret, 255, "C:\test.ini")
    14.     'NC is the number of characters copied to the buffer
    15.     If NC = 10 Then registered = True
    16.  End If
    17.  If registered = True Then Form1.Caption = "Registered!!"
    18. End Sub
    19.  
    20. Private Sub Command2_Click()
    21.  Unload Me
    22. End Sub
    23.  
    24. Private Sub Form_Load()
    25.     Dim Ret As String, NC As Long
    26.     'Create a buffer
    27.     Ret = String(255, 0)
    28.     'Retrieve the string
    29.     NC = GetPrivateProfileString(App.Title, "KeyName", "Default", Ret, 255, "C:\test.ini")
    30.     'NC is the number of characters copied to the buffer
    31.     If NC = 0 Then
    32.         'Write the setting to the file (c:\test.ini) under
    33.     '   Project1 -> Keyname
    34.     WritePrivateProfileString App.Title, "KeyName", "UnRegistered", "c:\test.ini"
    35.     End If
    36.     If NC = 12 Then registered = False
    37.     If registered = False Then Form1.Caption = "UnRegistered!"
    38.     If NC = 10 Then registered = True
    39.     If registered = True Then Form1.Caption = "Registered!!"
    40. End Sub
    Delphi uses its own TRegistry class, all you have to do is:

    TRegistry.Open.String 'Blah'

  12. #12
    Lively Member
    Join Date
    May 2005
    Posts
    125

    Re: What is the registry for?

    sorry i dont know Delphi, im using vb6 not sure if it would work all the same..Anyway, does anybody know how to write what i need to the registry? thanks.
    --- Science does not explain why things are what they are. What we get from Science is our interpretation of how things do what they do.
    --- No Scientific law of the universe is stable, we did not create it, and we will never understand all of its abilities.
    --- What we determine as reality is a mere assumption of what tomorrow will be based on what yesterday was.

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

    Re: What is the registry for?

    Here you go. Use this module.
    Attached Files Attached Files

  14. #14
    Addicted Member
    Join Date
    Feb 2005
    Location
    Cleveland, Ohio
    Posts
    255

    Re: What is the registry for?

    does anyone know if the registry is stored in a certain file.and if so where is it

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

    Re: What is the registry for?

    I'm not sure but I think it is the USER.DAT

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