RSS
热门关键字:
当前位置 : 主页>编程开发>Visual Basic>列表

验证Windowspassword

来源:我要研发网 作者: 时间:1970-01-01 点击:



|声明模块: 字串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

字串2

If InStr(sBuffer, Chr$(0)) Then

字串3

sBuffer = left$(sBuffer, InStr(sBuffer, Chr$(0)) - 1) 字串3

End If 字串6

字串6

GetWindowsLoginUserID = sBuffer 字串1

Else 字串3

Error! 字串7

GetWindowsLoginUserID = "" 字串6

End If

字串7

字串3

End Function 字串3

字串9

Public Function VerifyWindowsLoginU Password(ByVal Password As String) As Boolean 字串1

Dim rtn As Long, Match As Long 字串7

rtn = WNetVerifyPassword(Password, Match)

字串6

If rtn Then 字串4

VerifyWindowsLoginUserPassword = False

字串3

Else 字串1

VerifyWindowsLoginUserPassword = (Match $#@60;$#@62; 0)

字串8

End If

字串3

End Function 字串4

字串3

|窗体代码: 字串5

字串2

Private Sub cmdVerify_Click() 字串2

MsgBox "The password you supplied was " VerifyWindowsLoginUserPassword(txtPassword.Text)

字串1

End Sub

字串6

字串6

Private Sub Form_Load() 字串9

txtUsername = GetWindowsLoginUserID 字串7

txtUsername.Enabled = False 字串2

End Sub 字串3

字串6

最新评论共有 0 位网友发表了评论
发表评论
评论内容:不能超过250字,需审核,请自觉遵守互联网相关政策法规。
用户名: 密码:
匿名?
注册
相关文章