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")
stnicAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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 Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.