VB备份ACCESS数据库的方法,代码
VB备份ACCESS数据库的方法,代码
这个代码其实也适用于其它类型文件的复制,要修改一下其中的语句哦~Private Sub bak_Click()
Dim TargetFileName As String '目标文件名
On Error Resume Next
With cdlog1
.DialogTitle = "数据备份"
.InitDir = App.Path
.FileName = "backup.mdb"
.Filter = "(数据库)*.mdb|*.mdb"
.CancelError = True
.ShowSave
TargetFileName = .FileName
End With
If Right$(App.Path, 1) <> "\" Then spath = App.Path & "\"
ssource = spath & "db2.mdb"
On Error GoTo sjbf_error
If Dir$(TargetFileName) <> "" Then
If MsgBox("文件已存在,确认替换它!", vbYesNo + vbQuestion) = vbNo Then Exit Sub
Kill TargetFileName '删除文件
FileCopy ssource, TargetFileName '复制文件
'DBEngine.CompactDatabase ssource, TargetFileName '压缩文件
MsgBox "数据备份成功!", vbInformation
Else
FileCopy ssource, TargetFileName '复制文件
'DBEngine.CompactDatabase ssource, TargetFileName '压缩文件
MsgBox "数据备份成功!", vbInformation
End If
sjbf_error:
If Err = 70 Then
MsgBox "数据库正在使用,请关闭所有数据窗口,从新开始备份", vbExclamation
End If
End Sub
相关文档:
Private Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Long, ByVal dwReserved As Long) As Long
Private Const EWX_LOGOFF = 0
Private Const EWX_SHUTDOWN = 1
Private Const EWX_REBOOT = 2
Private Const EWX_FORCE = 4
Private closeTime As String
Sub AdjustTokenPrivilegesForNT()
......
Private Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Long, ByVal dwReserved As Long) As Long
Private Const EWX_LOGOFF = 0
Private Const EWX_SHUTDOWN = 1
Private Const EWX_REBOOT = 2
Private Const EWX_FORCE = 4
Private closeTime As String
Sub AdjustTokenPrivilegesForNT()
......
VB显示透明FLASH效果
演示效果:
代码如下:
公共声明区域
Option Explicit
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetW ......
程序隐形的原理
对于一个隐形程序而言,最基本的要求是:
1. 不在桌面出现界面;
2. 不在任务栏出现图标;
3. 程序名从任务管理器名单中消失。
Public Declare Function GetCurrentProcessId Lib “kernel32” () As Long
’获得当前进程ID函数的声明
Public Declare Functio ......