对access文件加密.即程序开始运行时.用TFileStream读取指定长度的字节是否为,提前写入的
数据,如果是则
begin
数据库没有被非法更改.
用TFileStream读取指定长度的字节(即加密点) 通过自己的算法还原.写回数据库(或生成临时数据库).
连接数据库.
end;
退出时:
删除临时库或(加密数据库
或者不用密码,用权限,在登登陆时存On_load加入
Option Compare Database
Sub SetStartupProperties()
Const DB_Text As Long = 10
Const DB_Boolean As Long = 1
ChangeProperty "StartupForm", DB_Text, "Customers"
ChangeProperty "StartupShowDBWindow", DB_Boolean, False
ChangeProperty "StartupShowStatusBar", DB_Boolean, False
ChangeProperty "AllowBuiltinToolbars", DB_Boolean, False
ChangeProperty "AllowFullMenus", DB_Boolean, True
ChangeProperty "AllowBreakIntoCode", DB_Boolean, False
ChangeProperty "AllowSpecialKeys", DB_Boolean, True
ChangeProperty "AllowBypassKey", DB_Boolean, True
End Sub
Function ChangeProperty(strPropName As String, varPropType As Variant, varPropValue As Variant) As Integer
Dim dbs As Object, prp As Variant
Const conPropNotFoundError = 3270
Set dbs = CurrentDb
On Error GoTo Change_Err
dbs.Properties(strPropName) = varPropValue
ChangeProperty = True
Change_Bye:
Exit Function
Change_Err:
If Err = conPropNotFoundError Then ' 找不到属性。
Set prp = dbs.CreateProperty(strPropName, _
varPropType, varPropValue)
dbs.Properties.Append prp
Resume Next
Else
' 未知的错误'。
ChangeProperty = False
Resume Change_Bye
End If
End Function
Private Sub Command0_Click()
On Error GoTo Err_Command0_Click
Provider=Microsoft.Jet.OLEDB.4.0;Password=a;Data Source=D:\database\database.mdb;Persist Security Info=True
连不上,报错“The Workgroup information is missing or opened exclusively by another user”