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

📄 form1.frm

📁 怎样获取Access数据库密码……Access数据库文件名:此数据库的密码为:
💻 FRM
字号:
VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "Comdlg32.ocx"
Begin VB.Form Form1 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "获取Access数据库密码"
   ClientHeight    =   2205
   ClientLeft      =   45
   ClientTop       =   435
   ClientWidth     =   4680
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   2205
   ScaleWidth      =   4680
   StartUpPosition =   3  '窗口缺省
   Begin VB.CommandButton cmdBrowse 
      Caption         =   "浏览"
      Height          =   255
      Left            =   3840
      TabIndex        =   5
      Top             =   480
      Width           =   735
   End
   Begin VB.CommandButton cmdOK 
      Caption         =   "获取密码"
      Height          =   375
      Left            =   3480
      TabIndex        =   4
      Top             =   1680
      Width           =   1095
   End
   Begin VB.TextBox txtPassword 
      Height          =   270
      Left            =   120
      TabIndex        =   3
      Top             =   1320
      Width           =   4455
   End
   Begin MSComDlg.CommonDialog CommonDialog1 
      Left            =   4080
      Top             =   840
      _ExtentX        =   847
      _ExtentY        =   847
      _Version        =   393216
   End
   Begin VB.TextBox txtSource 
      Height          =   270
      Left            =   120
      TabIndex        =   1
      Top             =   480
      Width           =   3615
   End
   Begin VB.Label Label2 
      Caption         =   "此数据库的密码为:"
      Height          =   255
      Left            =   120
      TabIndex        =   2
      Top             =   960
      Width           =   2055
   End
   Begin VB.Label Label1 
      Caption         =   "Access数据库文件名:"
      Height          =   255
      Left            =   120
      TabIndex        =   0
      Top             =   120
      Width           =   1935
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private DBName As String
Private oldPath As String

Private Sub cmdBrowse_Click()
    txtPassword.Text = ""
    oldPath = DBName
    CommonDialog1.InitDir = DBName
    CommonDialog1.Filter = "Access数据库文件(*.mdb)|*.mdb"
    CommonDialog1.ShowOpen
    DBName = CommonDialog1.FileName
    If DBName = "" Then
        DBName = oldPath
        Exit Sub
    End If
    txtSource.Text = DBName
End Sub
Private Sub cmdOK_Click()
    txtPassword.Text = ""
    If Dir(txtSource.Text) = "" Then
        MsgBox "数据库文件不存在,请重新指定!", vbInformation, "注意"
        txtPassword.Text = "指定的文件不存在"
        txtSource.SetFocus
        Exit Sub
    End If
    If LCase(Right(txtSource.Text, 3)) <> "mdb" Then
        MsgBox "指定的文件不是Access数据库文件,请重新指定!", vbInformation, "注意"
        txtPassword.Text = "指定的文件不是Access数据库文件"
        txtSource.SetFocus
        Exit Sub
    End If
On Error GoTo PasswordErr
    Dim strBytes(13) As Byte
    Open txtSource.Text For Binary Access Read As #1
    Get #1, 67, strBytes
    Close #1
    Dim strPW As String
    If (strBytes(0) Xor 134) = 0 Then
        txtPassword.Text = "该数据库没有密码"
    Else
        strPW = strPW & Chr$(strBytes(0) Xor &H86)
        strPW = strPW & Chr$(strBytes(1) Xor &HFB)
        strPW = strPW & Chr$(strBytes(2) Xor &HEC)
        strPW = strPW & Chr$(strBytes(3) Xor &H37)
        strPW = strPW & Chr$(strBytes(4) Xor &H5D)
        strPW = strPW & Chr$(strBytes(5) Xor &H44)
        strPW = strPW & Chr$(strBytes(6) Xor &H9C)
        strPW = strPW & Chr$(strBytes(7) Xor &HFA)
        strPW = strPW & Chr$(strBytes(8) Xor &HC6)
        strPW = strPW & Chr$(strBytes(9) Xor &H5E)
        strPW = strPW & Chr$(strBytes(10) Xor &H28)
        strPW = strPW & Chr$(strBytes(11) Xor &HE6)
        strPW = strPW & Chr$(strBytes(12) Xor &H13)
        txtPassword.Text = strPW
    End If
    Exit Sub
PasswordErr:
    MsgBox "发生错误,无法解读密码!" & vbNewLine & "错误:" & Err.Description, vbExclamation, "错误"
End Sub
Private Sub Form_Load()
    DBName = App.Path
End Sub

Private Sub txtSource_GotFocus()
    With txtSource
        .SelStart = 0
        .SelLength = Len(.Text)
    End With
End Sub

⌨️ 快捷键说明

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