|
-
Aug 10th, 2000, 06:09 PM
#1
Thread Starter
Registered User
Hello, i was jsut wondering, i am making a loggin program to a bigger program, but i have no idea how to make it so they can choose a Password and Username...how would i do such a thing? If u know the answer please post
THanks for listening
-
Aug 10th, 2000, 06:19 PM
#2
Frenzied Member
why not just make it so that it stores the user name and passsword on the computer?
NXSupport - Your one-stop source for computer help
-
Aug 10th, 2000, 06:36 PM
#3
Store the username and password in the Registry. For additional security, you can encrypt them.
-
Aug 10th, 2000, 06:45 PM
#4
I'm not sure about using the Registry. Never really used it, but here is how to do it using an INI file.
Code:
Public Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long
Public Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As Any, ByVal lpFileName As String) As Long
Public Function ReadINI(strsection As String, strkey As String, strfullpath As String) As String
Dim strbuffer As String
Let strbuffer$ = String$(750, Chr$(0&))
Let ReadINI$ = Left$(strbuffer$, GetPrivateProfileString(strsection$, ByVal LCase$(strkey$), "", strbuffer, Len(strbuffer), strfullpath$))
End Function
Public Sub WriteINI(strsection As String, strkey As String, strkeyvalue As String, strfullpath As String)
Call WritePrivateProfileString(strsection$, UCase$(strkey$), strkeyvalue$, strfullpath$)
End Sub
'We will use Combo boxes as name and password.
'Combo1.text = name
'Combo2.text = password
Private Sub Form_Load()
Combo1.text = readini("UserPW.ini", "User", "C:\Windows\UserPW.ini")
Combo2.text = readini("UserPW.ini", "Password", "C:\Windows\UserPW.ini")
End Sub
Private Sub Form_Unload(Cancel As Integer)
Call writeini("UserPW.ini", "User", "" & Combo1.text & "", "C:\Windows\UserPW.ini")
Call writeini("UserPW.ini", "Password", "" & Combo2.text & "", "C:\Windows\UserPW.ini")
End Sub
'If there are multiple users:
Public Sub List_Save(TheList As ComboBox, FileName As String)
On Error Resume Next
Dim Save As Long
Dim fFile As Integer
fFile = FreeFile
Open FileName For Output As fFile
For Save = 0 To TheList.ListCount - 1
Print #fFile, TheList.List(Save)
Next Save
Close fFile
End Sub
'Call List_Save(Combo1, "C:\Windows\UserPW.txt")
'Call List_Save(Combo2, "C:\Windows\UserPW.txt")
Public Sub List_Add(List As ComboBox, txt As String)
List.AddItem txt
End Sub
'Call List_Add(Combo1, "User")
Public Sub List_Load(TheList As ComboBox, FileName As String)
On Error Resume Next
Dim TheContents As String
Dim fFile As Integer
fFile = FreeFile
Open FileName For Input As fFile
Do
Line Input #fFile, TheContents$
Call List_Add(TheList, TheContents$)
Loop Until EOF(fFile)
Close fFile
End Sub
'Call List_Load(Combo1, "C:\Windows\UserPW.txt")
'Call List_Load(Combo2, "C:\Windows\UserPW.txt")
Remember, this is just an example. I suggest you do as Megatron said and store it in the Registry.
Get the point? Hope that helps.
[Edited by Matthew Gates on 08-10-2000 at 07:48 PM]
-
Aug 10th, 2000, 07:51 PM
#5
Monday Morning Lunatic
Here's a sample project: http://www.parksie.uklinux.net/registry.zip
[Edited by parksie on 08-10-2000 at 08:53 PM]
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
-
Aug 10th, 2000, 08:34 PM
#6
Thread Starter
Registered User
Thanks Guys!
Thanks everyone for the help!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|