• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 167
  • Last Modified:

Registry 145 Points

Hello Out There, I'm using visual basic 5.0 and am trying to make a small program which will track user names and passwords. I can get it to write the user name and password to the registry one time per the code below. I would like to see some "working code" which would show me how to list 10 user names and passwords and check all 10 entries for the correct name and password ? Thank You
stnic

Call savestring(HKEY_CURRENT_USER, "Software\GGfile", "Name", txtUserName.Text)
 
 Call savestring(HKEY_CURRENT_USER, "Software\GGfile", "Password", txtPassword.Text)

strName = getstring(HKEY_CURRENT_USER, "Software\GGfile", "Name")

strPassword = getstring(HKEY_CURRENT_USER, "Software\GGfile", "Password")
0
stnic
Asked:
stnic
  • 8
  • 3
1 Solution
 
kamallCommented:
Use the VB statements SaveSetting and GetSetting to write/read to/from the registry.

Example:
SaveSetting "MyApplication","UserNames", "1", "nnnnn"
SaveSetting "MyApplication","Passwords", "1", "ppppp"

SaveSetting "MyApplication","UserNames", "2", "nnnnn"
SaveSetting "MyApplication","Passwords", "2", "ppppp"

etc.

If you need sample code, leave me a comment.
0
 
AnswerTheManCommented:
if it was one user - well use the registry, but if in your case - the
Registry is not the place for that.
you should use a littel Database to store all users with their passwords.

there are 2 main reasons for that :
1.
registry space is limited and spending it for such things is bad concept.
2.
security.
everyone can read from registry. what's the value of a password if anyone can see it ?
Database is more secure (from most users), since the data is saved binary mode, you can protect it by a password, so only you and your application can see what's in it.


--------------
a little mdb tabel would be the best.
0
 
kamallCommented:
I would really suggest that you encrypt the data and save them either in a file or in a database as AnswerTheMan said.
If the usernames are just 10 or so, then you can save them in the registry without problems.
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
stnicAuthor Commented:
kamall, Thank You and Thanks to AnswerTheMan. You both make a lot of sense even to me HA!. Yes, I still ride on the "novice train".
I would like the example that you refer to so that i won't screw things up. I am using textboxes to collect the username and passwords so please allow for this in your code. I just am to lame at this point not to use 10 textboxes, no what i mean ?
Thanks in advance for the Code!
If I use more than 10 passwords, i will be back here for the AnswerTheMan's Code for using a database...
stnic
0
 
kamallCommented:
Well,
comment me your e-mail address so I can send you the sample project. I will also post it here but it will be easier for you to get a working project; right?
0
 
kamallCommented:
hellooooooo......
where is your e-mail address?
0
 
stnicAuthor Commented:
Here tis :
ab356@oak-web.washington-ch.oh.us

I Thank You
stnic
0
 
kamallCommented:
It is in your mailbox.
P.S. Don't care about where it will save the info on the user machine. The program will find it wherever they are.

Code listing:

Dim LastIndex As Integer

Private Sub Command1_Click(Index As Integer)

    Select Case Index
    Case Is = 0 'save new user
        SaveSetting "UserLog", "UserName", CStr(LastIndex + 1), Text1(0)
        SaveSetting "UserLog", "Password", CStr(LastIndex + 1), Text1(1)
        LastIndex = LastIndex + 1
        MsgBox "User added to the registry"
    Case Is = 1 'check user
        For x = 1 To 10
        tempname = GetSetting("UserLog", "UserName", CStr(x))
        temppass = GetSetting("UserLog", "Password", CStr(x))
        If tempname = Text1(3) And temppass = Text1(2) Then
            MsgBox "User found"
            Flag = 1
            Exit For
        End If
        Next
        If Flag = 0 Then MsgBox "User not found"
    End Select
   
End Sub

Private Sub Form_Load()

    'get the last user index
    For x = 1 To 10
        z = GetSetting("UserLog", "UserName", CStr(x))
        If x = 1 And z = "" Then
            LastIndex = 0
            Exit For
        End If
        If z = "" And x > 1 Then
            LastIndex = x - 1
            Exit For
        End If
    Next
    'MsgBox LastIndex

End Sub

0
 
kamallCommented:
First run the project, add a couple of users, and then enter a username and a password and check for their existance.
Regards.
0
 
kamallCommented:
Is it Ok?
Just want to know because I have to disconnect right now.
0
 
stnicAuthor Commented:
kamall, Works very nice for what i am doing ! I appreciate your hanging in there with me !
Thanks Again
stnic
0
 
kamallCommented:
Thank you stnic, and you are welcome.
Now I disconnect and go to bed with happiness :-))
Best regards.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 8
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now