|声明模块: 字串8
Option Explicit
字串7
字串9
Declare Function GetUserName Lib "advapi32.dll" Alias _ 字串8
"GetUserNameA" (ByVal lpBuffer As String, _ 字串2
nSize As Long) As Long
字串8
字串5
Private Declare Function WNetVerifyPassword Lib "mpr.dll" Alias _
字串5
"WNetVerifyPasswordA" (ByVal lpszPassword As String, _ 字串9
ByRef pfMatch As Long) As Long 字串5
字串5
Public Function GetWindowsLoginUserID() As String 字串4
Dim rtn As Long 字串8
Dim sBuffer As String
字串9
Dim lSize As Long 字串6
字串8
sBuffer = String$(260, Chr$(0)) 字串3
lSize = Len(sBuffer)
字串9
rtn = GetUserName(sBuffer, lSize)
字串9
If rtn Then 字串2
sBuffer = left$(sBuffer, lSize) 字串5
字串9
Reformat string
If InStr(sBuffer, Chr$(0)) Then
sBuffer = left$(sBuffer, InStr(sBuffer, Chr$(0)) - 1) 字串3
End If 字串6
字串6
GetWindowsLoginUserID = sBuffer 字串1
Else 字串3
Error! 字串7
GetWindowsLoginUserID = "" 字串6
End If
End Function 字串3
Public Function VerifyWindowsLoginU Password(ByVal Password As String) As Boolean 字串1
Dim rtn As Long, Match As Long 字串7
rtn = WNetVerifyPassword(Password, Match)
If rtn Then 字串4
VerifyWindowsLoginUserPassword = False
字串3
Else 字串1
VerifyWindowsLoginUserPassword = (Match $#@60;$#@62; 0)
End If
字串3
End Function 字串4
字串3
|窗体代码: 字串5
字串2
Private Sub cmdVerify_Click() 字串2
MsgBox "The password you supplied was " VerifyWindowsLoginUserPassword(txtPassword.Text)
End Sub
字串6
Private Sub Form_Load() 字串9
txtUsername = GetWindowsLoginUserID 字串7
txtUsername.Enabled = False 字串2
End Sub 字串3
字串6
![我要研发网[www.51dev.com]](/templets/images/toplogo.gif)
