Hey people, I want that my app can takes the winuser logon for to validate the access to the app, but when I compare this data it doesn´t match, heres is my code:
Option Explicit
Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpbuffer As String, nSize As Long) As Long
Dim sBuffer As String
Dim lSize As Long
Dim clave as String
Public OK As Boolean
Private Sub Form_Load()
sBuffer = Space$(255)
lSize = Len(sBuffer)
Call GetUserName(sBuffer, lSize)
clave = Left$(sBuffer, lSize)
End Sub
Private Sub aceptar_Click()
If txtuser.Text = clave Then
OK = True
MsgBox "bievenido", vbCritical
'Me.Hide
Else
MsgBox "La contraseña no es válida; vuelva a intentarlo", , "Inicio de sesión"
txtuser.SetFocus
txtuser.SelStart = 0
txtuser.SelLength = Len(txtuser.Text)
End If
End Sub
So txtuser.text=clave doesn´t match, and my logon is "tamayo", and the value of txtuser.text is "tamayo", why it doesn´t match?
Thanks
Option Explicit
Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpbuffer As String, nSize As Long) As Long
Dim sBuffer As String
Dim lSize As Long
Dim clave as String
Public OK As Boolean
Private Sub Form_Load()
sBuffer = Space$(255)
lSize = Len(sBuffer)
Call GetUserName(sBuffer, lSize)
clave = Left$(sBuffer, lSize)
End Sub
Private Sub aceptar_Click()
If txtuser.Text = clave Then
OK = True
MsgBox "bievenido", vbCritical
'Me.Hide
Else
MsgBox "La contraseña no es válida; vuelva a intentarlo", , "Inicio de sesión"
txtuser.SetFocus
txtuser.SelStart = 0
txtuser.SelLength = Len(txtuser.Text)
End If
End Sub
So txtuser.text=clave doesn´t match, and my logon is "tamayo", and the value of txtuser.text is "tamayo", why it doesn´t match?
Thanks