www.pudn.com > VerifyPass.zip > frmDemo.frm
VERSION 5.00
Begin VB.Form frmDemo
BorderStyle = 1 'Fixed Single
Caption = "登录"
ClientHeight = 2145
ClientLeft = 45
ClientTop = 330
ClientWidth = 4080
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 2145
ScaleWidth = 4080
StartUpPosition = 3 '窗口缺省
Begin VB.TextBox txtPass
Height = 255
IMEMode = 3 'DISABLE
Left = 1260
PasswordChar = "*"
TabIndex = 2
Text = "txtPass"
Top = 780
Width = 1755
End
Begin VB.CommandButton cmdCheck
Caption = "确定"
Default = -1 'True
Height = 435
Left = 2400
TabIndex = 1
Top = 1440
Width = 1035
End
Begin VB.TextBox txtUser
Height = 255
Left = 1260
TabIndex = 0
Text = "txtUser"
Top = 300
Width = 1755
End
Begin VB.Label Label2
AutoSize = -1 'True
Caption = "口 令:"
Height = 180
Left = 360
TabIndex = 4
Top = 840
Width = 630
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "用户名:"
Height = 180
Left = 360
TabIndex = 3
Top = 300
Width = 630
End
End
Attribute VB_Name = "frmDemo"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'*****************************************************
'//
'// VerifyPass.vbp 1999/08/19
'//
'// 作者:陈国强 alone@telekbird.com.cn
'// 原子数据工作室 http://www.quanqiu.com.cn
'//
'// 您可以自由的拷贝并使用本程序
'//
'*****************************************************
Option Explicit
Private Declare Function GetUserName Lib "Advapi32.dll" Alias "GetUserNameA" _
(ByVal lpBuffer As String, _
nSize As Long) As Long
Private Declare Function WNetVerifyPassword Lib "mpr.dll" Alias "WNetVerifyPasswordA" ( _
ByVal lpszPassword As String, _
ByRef pfMatch As Long) As Long
Private Sub cmdCheck_Click()
Dim strUserName As String
Dim n As Long
Dim di As Long
Dim strPassTemp As String
Dim CheckUser, CheckPass As Boolean
di = GetUserName(strUserName, n)
strUserName = String(n - 1, 0)
di = GetUserName(strUserName, n)
CheckUser = (txtUser.Text = strUserName)
If Len(txtPass.Text) <= 0 Then
strPassTemp = ""
Else
strPassTemp = txtPass.Text
End If
CheckPass = (VerifyPass(strPassTemp))
If CheckUser And CheckPass Then
MsgBox "合法用户!"
Else
MsgBox "非法用户!"
End If
End Sub
Function VerifyPass(strPass As String) As Boolean
Dim lResult As Long
If (WNetVerifyPassword(strPass, lResult)) <> 0 Then
MsgBox "System Error!"
Else
VerifyPass = IIf(lResult <> 0, True, False)
End If
End Function
Private Sub Form_Load()
txtUser.Text = ""
txtPass.Text = ""
End Sub