I am needing a way to validate a password against stored passwords. I need the program to only ask the user for this password once. Can anyone give me some ideas? Thanks
Printable View
I am needing a way to validate a password against stored passwords. I need the program to only ask the user for this password once. Can anyone give me some ideas? Thanks
Why not just keep the password in a variable?
You could encrypt your password ;)
Are you looking to work with an INI or the Registry? For both, make a value that tells you, something like:
INI:
Password=Yes
Registry:
HKEY_LOCAL_MACHINE\Software\MyApp\Data
Name Data
Password Yes
I am not sure about the Registry, but here's how to do it the INI way.
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
Usage:
x = readini("Myapp.ini", "Password", "C:\Windows\Myapp.ini")
If x = "Yes" Then
'Password stored
Else
i = Inputbox("Password?")
Call writeini("Myapp.ini", "PW", "" & i & "", "C:\Windows\Myapp.ini")
Call writeini("Myapp.ini", "Password", "Yes", "C:\Windows\Myapp.ini")
End If
[Edited by Matthew Gates on 08-22-2000 at 03:59 PM]
See this thread: http://forums.vb-world.net/showthrea...threadid=25934