⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frmlogin.frm

📁 实现图像控制,云台解码器控制,站点选择(配有Access数据库).
💻 FRM
字号:
VERSION 5.00
Begin VB.Form frmLogin 
   BorderStyle     =   3  'Fixed Dialog
   Caption         =   "登录"
   ClientHeight    =   1575
   ClientLeft      =   30
   ClientTop       =   330
   ClientWidth     =   3825
   Icon            =   "frmLogin.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   1575
   ScaleWidth      =   3825
   ShowInTaskbar   =   0   'False
   StartUpPosition =   2  '屏幕中心
   Tag             =   "登录"
   Begin VB.ComboBox Combo1 
      Height          =   276
      Left            =   1320
      TabIndex        =   6
      Text            =   "A"
      Top             =   120
      Width           =   2412
   End
   Begin VB.CommandButton cmdCancel 
      Cancel          =   -1  'True
      Caption         =   "取消"
      Height          =   360
      Left            =   2100
      TabIndex        =   5
      Tag             =   "取消"
      Top             =   1020
      Width           =   1140
   End
   Begin VB.CommandButton cmdOK 
      Caption         =   "确定"
      Default         =   -1  'True
      Height          =   360
      Left            =   495
      TabIndex        =   4
      Tag             =   "确定"
      Top             =   1020
      Width           =   1140
   End
   Begin VB.TextBox txtPassword 
      Height          =   260
      IMEMode         =   3  'DISABLE
      Left            =   1320
      PasswordChar    =   "*"
      TabIndex        =   1
      Top             =   480
      Width           =   2412
   End
   Begin VB.TextBox txtUserName 
      Height          =   260
      Left            =   3480
      TabIndex        =   3
      Top             =   1320
      Visible         =   0   'False
      Width           =   2325
   End
   Begin VB.Label lblLabels 
      Caption         =   "密码(&P):"
      Height          =   252
      Index           =   1
      Left            =   120
      TabIndex        =   0
      Tag             =   "密码(&P):"
      Top             =   540
      Width           =   1080
   End
   Begin VB.Label lblLabels 
      AutoSize        =   -1  'True
      Caption         =   "用户名称(&U):"
      Height          =   180
      Index           =   0
      Left            =   108
      TabIndex        =   2
      Tag             =   "用户名称(&U):"
      Top             =   156
      Width           =   1188
   End
End
Attribute VB_Name = "frmLogin"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
' from hfdb2
Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpbuffer As String, nSize As Long) As Long

Public OK As Boolean

Private Sub Combo1_Change()
    txtUserName.Text = Combo1.List(Combo1.ListIndex) '990527

End Sub

Private Sub Form_Load()
    Dim sBuffer As String
    Dim lSize As Long
    
    Dim MySettings As Variant, intSettings As Integer
    
    LastUserName = GetSetting(regTitle, regSection, "LastUserName", "")
    If LastUserName = "" Then
        sBuffer = Space$(255)
        lSize = Len(sBuffer)
        Call GetUserName(sBuffer, lSize)
        If lSize > 0 Then
            txtUserName.Text = Left$(sBuffer, lSize)
        Else
            txtUserName.Text = "A" 'vbNullString
        End If
            txtUserName.Text = "A" ' lgh 990527
            txtPassword.Text = "A" ' lgh 990527
        SaveSetting regTitle, regSection, "LastUserName", txtUserName.Text
        SaveSetting regTitle, regSection, "A", "A"
        SaveSetting appname:=regTitle, section:=regSection, _
                Key:=txtUserName.Text, setting:=txtPassword.Text
        Beep
        MsgBox "系统探测到这是您首次在本机运行主控软件。" & vbCr _
            & "您将以管理员身份登陆,现在用户名和密码都为“A”。" _
            & "请及时更改密码并将密码记录下来,存放在安全的地方。", vbInformation, "首次登陆"

    Else
        txtUserName.Text = LastUserName
    End If
    
    Combo1.Clear
    MySettings = GetAllSettings(appname:=regTitle, section:=regSection)
    For intSettings = LBound(MySettings, 1) To UBound(MySettings, 1)
        'Debug.Print MySettings(intSettings, 0), MySettings(intSettings, 1)
        'If MySettings(intSettings, 0) <> "test0000" Then _
         '   List1.AddItem MySettings(intSettings, 0)
        If MySettings(intSettings, 0) <> "LastUserName" Then
            Combo1.AddItem (MySettings(intSettings, 0))
        End If
    Next intSettings
    LastUserName = GetSetting(regTitle, regSection, "LastUserName", "")
    For intSettings = 0 To Combo1.ListCount - 1
        If Combo1.List(intSettings) = LastUserName Then
            Combo1.ListIndex = intSettings
        End If
    Next intSettings
 
    Combo1.Refresh
    
    
End Sub

Private Sub cmdCancel_Click()
    OK = False
    Me.Hide
End Sub

Private Sub cmdOK_Click()
    'To Do - 创建测试密码是否正确
    '检查正确密码
        Close #2
        Open strLogFilePath For Append As #2 'lgh99.01.19
    Dim UserExist As Boolean
    Dim MySettings As Variant, intSettings As Integer
    
    txtUserName.Text = Combo1.List(Combo1.ListIndex) '990527
    
    If txtPassword.Text = "A" Then
        OK = True
        UserName = "A"
            SaveSetting regTitle, regSection, "LastUserName", "A"
            
        Print #2, Date & ","; Time & ",超级用户登陆成功。"
        Me.Hide
        Exit Sub
    End If
    
    UserExist = False
    MySettings = GetAllSettings(appname:=regTitle, section:=regSection)
    For intSettings = LBound(MySettings, 1) To UBound(MySettings, 1)
        'Debug.Print MySettings(intSettings, 0), MySettings(intSettings, 1)
        'If MySettings(intSettings, 0) <> "test0000" Then _
         '   List1.AddItem MySettings(intSettings, 0)
        If MySettings(intSettings, 0) = txtUserName.Text Then UserExist = True
    Next intSettings
    If UserExist = True Then
        Password = GetSetting(regTitle, regSection, txtUserName.Text)     ' "Name", ""
        If txtPassword.Text = Password Then
            SaveSetting regTitle, regSection, "LastUserName", txtUserName.Text
            UserName = txtUserName.Text
            OK = True
                    Print #2, Date & ","; Time & ",用户" & txtUserName.Text & "登陆成功。"

            Me.Hide
        Else
            MsgBox "密码错误,再试一次!", vbExclamation, "登录"
            txtPassword.SetFocus
            txtPassword.SelStart = 0
            txtPassword.SelLength = Len(txtPassword.Text)
                    Print #2, Date & ","; Time & ",用户" & txtUserName.Text & "登陆失败。"
        End If
    Else
            MsgBox "用户名不存在!", vbExclamation, "登录"
                    Print #2, Date & ","; Time & ",用户" & txtUserName.Text & "登陆失败。(用户名不存在)"
    End If
        Close #2
        'Open strLogFilePath For Append As #2 'lgh99.01.19
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -