?? frmtool.frm
字號:
Left = 4560
TabIndex = 7
Top = 3615
Width = 1095
_extentx = 1931
_extenty = 609
font = "frmTool.frx":0B6E
caption = "登錄(&U)"
forecolor = -2147483630
End
Begin Manage.uclMainPic uclMainPic1
Height = 3510
Left = 0
TabIndex = 9
Top = 0
Width = 6975
_extentx = 12303
_extenty = 6191
End
End
Attribute VB_Name = "frmTool"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
' 數據庫連接方式編輯器 V0.89 測試版
'
Option Explicit
Dim strTemp As String '臨時字符串
Dim intNumber As Integer
Private WithEvents EncryptGost As clsGost '加密算法
Attribute EncryptGost.VB_VarHelpID = -1
Private EncryptObject As Object
Dim strPath As String
Dim blnFileNull As Boolean 'T:文件內容為空,或文件不存在,F:文件有內容
Dim blnStart As Boolean 'T: 啟動 F:不是啟動
Private Sub chkPass_Click()
txtConceal.Enabled = IIf(chkPass.Value = Checked, True, False)
txtConceal.BackColor = IIf(chkPass.Value = Checked, &HFFFFFF, &H8000000F)
lblPassword.Enabled = txtConceal.Enabled
End Sub
Private Sub cmdFile_Click()
On Error Resume Next
cdgFile.DialogTitle = "加載Access數據庫"
cdgFile.Filter = "Microsoft Access (*.mdb)|*.mdb|"
cdgFile.Filename = ""
cdgFile.ShowOpen
strTemp = cdgFile.Filename
If Len(strTemp) = 0 Then Exit Sub
txtDatabase.Text = strTemp
End Sub
Private Sub Form_Load()
On Error GoTo errNext
blnStart = True
If gblnLoadError = True Then DisSysMenu Me.hwnd, 6 '右上角關閉按鈕無效
' PrevWndFunc = SetWindowLong(txtConceal.hwnd, GWL_WNDPROC, AddressOf MessageFunc)
' PrevWndFunc = SetWindowLong(txtPassword.hwnd, GWL_WNDPROC, AddressOf MessageFunc)
cboProvider.ListIndex = 0
gstrNowLink = ""
If gblnLoadError = False Then
CmdExit.Caption = "關閉(&C)"
Else
CmdExit.Caption = "退出(&Q)"
End If
Set EncryptGost = New clsGost
Set EncryptObjects.Object = EncryptGost
EncryptObjects.Name = "Gost"
Set EncryptObject = EncryptObjects.Object
strPath = App.Path & "\corp.dat"
blnFileNull = True
If Len(Dir(strPath)) <> 0 Then '文件是否存在
If FileLen(strPath) > 13 And FileLen(strPath) < 50000 Then '文件內容是否為空,13為此密碼的長度
blnFileNull = False
Call EncryptObject.DecryptFile(strPath, strPath, "$ fk#ci(%2^d9") '解密
Open strPath For Binary As #1
gstrNowLink = Trim(Input$(LOF(1), #1))
Close #1
Call EncryptObject.EncryptFile(strPath, strPath, "$ fk#ci(%2^d9") '加密
cboProvider.Text = Mid(gstrNowLink, 10, 23)
intNumber = InStr(1, gstrNowLink, ";User ID=", vbTextCompare) + 9
If intNumber > 9 Then txtName.Text = Mid(gstrNowLink, intNumber, InStr(intNumber, gstrNowLink, ";Jet OLEDB", vbTextCompare) - intNumber)
intNumber = InStr(1, gstrNowLink, ";Jet OLEDB:Database Password=", vbTextCompare) + 29
If intNumber > 29 Then txtPassword.Text = Mid(gstrNowLink, intNumber, InStr(intNumber, gstrNowLink, ";Data Source", vbTextCompare) - intNumber)
intNumber = InStr(1, gstrNowLink, ";Data Source=", vbTextCompare) + 13
If intNumber > 13 Then txtDatabase.Text = Mid(gstrNowLink, intNumber, InStr(intNumber, gstrNowLink, ";Persist Security", vbTextCompare) - intNumber)
If Len(txtPassword.Text) = 0 Then
txtConceal.Enabled = False
txtConceal.BackColor = &H8000000F
lblPassword.Enabled = False
chkPass.Value = Checked
Else
txtConceal.Text = Mid(" abcdefghijklmnopqrstuvwxyz", 1, Len(txtPassword.Text) * 2)
End If
'End If
Else
Kill strPath
Open strPath For Output As #1 '建文件
Close #1
End If
Else
Open strPath For Output As #1 '建文件
Close #1
End If
blnStart = False
Exit Sub
errNext:
blnStart = False
Call ErrMsg(Err.Number, Err.Description)
End Sub
Private Sub cmdDel_Click() '刪除
On Error GoTo errNext
If Len(Dir(strPath)) <> 0 Then
If MsgBox("確實要刪除此設置嗎", vbInformation + vbYesNo) = vbYes Then
Kill strPath
Open strPath For Output As #1
Close #1
gstrNowLink = ""
txtName.Text = "" '清空各項內容
txtConceal.Text = ""
txtDatabase.Text = ""
MsgBox "設置被成功刪除!", vbInformation
End If
End If
Exit Sub
errNext:
Call ErrMsg(Err.Number, Err.Description)
End Sub
Private Sub cmdExit_Click() '退出
On Error Resume Next
If gblnLoadError = False Then
Unload Me
MDIMain.Enabled = True
Else
Call Shutdown
End If
End Sub
Private Sub cmdSave_Click() '保存
On Error GoTo errNext
If Len(Trim(txtDatabase.Text)) = 0 Then MsgBox "數據庫路徑不能為空,請輸入路徑后再進行保存.", vbExclamation: txtDatabase.SetFocus: Exit Sub
If chkPass.Value = Checked Or Len(Trim(txtPassword.Text)) = 0 Then '無密碼
strTemp = "Provider=" & cboProvider.Text & ";Data Source=" & Trim(txtDatabase.Text) & ";Persist Security Info=True"
Else '有密碼
strTemp = "Provider=" & cboProvider.Text & ";User ID=" & Trim(txtName.Text) & ";Jet OLEDB:Database Password=" & Trim(txtPassword.Text) & ";Data Source=" & Trim(txtDatabase.Text) & ";Persist Security Info=True"
End If
If (FileLen(strPath) > 13 And FileLen(strPath) < 50000) And Len(Dir(strPath)) <> 0 Then '文件內容為空,或文件不存在
If blnFileNull = False Then Call EncryptObject.DecryptFile(strPath, strPath, "$ fk#ci(%2^d9") '解密
ElseIf (FileLen(strPath) <= 13 Or FileLen(strPath) >= 50000) And Len(Dir(strPath)) <> 0 Then
Kill strPath
End If
Open strPath For Output As #1
Print #1, strTemp
Close #1
Call EncryptObject.EncryptFile(strPath, strPath, "$ fk#ci(%2^d9") '加密
MsgBox "保存成功!", vbInformation
Exit Sub
errNext:
Open strPath For Output As #1 '加密出錯就寫空文件
Print #1, ""
Close #1
Kill strPath
Open strPath For Output As #1
Close #1
Call ErrMsg(Err.Number, Err.Description)
End Sub
Private Sub cmdTest_Click() '測試連接
Dim conn As New ADODB.Connection
lblText.Caption = ""
If Len(Trim(txtDatabase.Text)) = 0 Then MsgBox "數據庫路徑不能為空,請輸入路徑后再測試連接.", vbExclamation: txtDatabase.SetFocus: Exit Sub
cmdTest.Enabled = False
If chkPass.Value = Checked Or Len(Trim(txtPassword.Text)) = 0 Then '無密碼
strTemp = "Provider=" & cboProvider.Text & ";Data Source=" & Trim(txtDatabase.Text) & ";Persist Security Info=True"
Else '有密碼
strTemp = "Provider=" & cboProvider.Text & ";User ID=" & Trim(txtName.Text) & ";Jet OLEDB:Database Password=" & Trim(txtPassword.Text) & ";Data Source=" & Trim(txtDatabase.Text) & ";Persist Security Info=True"
End If
On Error GoTo ErrLink
With conn
.CursorLocation = adUseClient
.CommandTimeout = 10
.Open strTemp
lblText.ForeColor = &HFF0000
lblText.Caption = "測試連接成功,此設置可用!"
End With
Set conn = Nothing
cmdTest.Enabled = True
Exit Sub
ErrLink: '發生錯誤,則連接失敗
lblText.ForeColor = &HFF&
lblText.Caption = "測試連接失敗,請重新設置!"
Set conn = Nothing
cmdTest.Enabled = True
Call ErrMsg(Err.Number, Err.Description)
End Sub
Private Sub cmdReStats_Click()
blnLogout = False
Call Shutdown
Call Main
End Sub
Private Sub Form_Unload(Cancel As Integer)
Set EncryptGost = Nothing
Set EncryptObject = Nothing
End Sub
Private Sub txtConceal_Change()
If blnStart = True Then Exit Sub
Dim D As String, e As String, C As Integer
D = " abcdefghijklmnopqrstuvwxyz"
txtPassword.SetFocus
C = Len((txtPassword.Text))
e = Mid(D, C + 1, 1) & (C + 1)
txtConceal.Text = Mid(txtConceal.Text & e, 1, C * 2)
txtConceal.SetFocus
SendKeys "{end}"
End Sub
Private Sub txtConceal_KeyPress(KeyAscii As Integer)
If KeyAscii = 8 Then
txtConceal.SetFocus
SendKeys "{end}"
If Len(txtPassword.Text) = 0 Then Exit Sub
txtPassword.Text = Mid(txtPassword.Text, 1, Len(txtPassword.Text) - 1)
Else
txtPassword.Text = txtPassword.Text & Chr(KeyAscii)
End If
End Sub
Private Sub txtPassword_GotFocus()
txtConceal.SetFocus
SendKeys "{end}"
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -