Sabtu, 05 Februari 2011

Membuat Program Backup Database

Program ini cukup penting sebagai sarana Backup Data, walaupun Windows Explorer
mampu melakukannya, tidak ada salahnya jika kita coba membuat programnya dalam
Visual Basic.


Listing Program
Private Declare Function SHFileOperation Lib "Shell32.dll"
Alias "SHFileOperationA" (lpFileOP As shfileopstruct) As
Long
Private Const FO_copy = &H2
Private Const fof_allowundo = &H40
Private Type shfileopstruct
hwnd As Long
wfunc As Long
pfrom As String
pto As String
Fflags As Integer
Faborted As Boolean
hnamemaps As Long
sprogress As String
End Type
Public Sub copy(ByVal asal As String, ByVal tujuan As
String)

Dim x As shfileopstruct
With x
.hwnd = 0
.wfunc = FO_copy
.pfrom = asal & vbNullChar & vbNullChar
.pto = tujuan & vbNullChar & vbNullChar
.Fflags = fof_allowundo
End With
SHFileOperation x
End Sub

Private Sub Form_Load()
Dir1.Path = "C:\Program Pelengkap"
Dir2.Path = "C:\"
End Sub

Private Sub Command1_Click()
On Error Resume Next
If Text1 = "" Then
MsgBox "Anda belum memilih file yang akan dicopy"
Exit Sub
ElseIf Text2 = "" Then
MsgBox "Anda tidak memilih direktori tujuan peng-Copyan"
Exit Sub
End If
copy Text1.Text, Text2.Text
MsgBox "File sudah di copy"
End Sub

Private Sub Command1_KeyPress(Keyascii As Integer)
If Keyascii = 27 Then Unload Me
End Sub

Private Sub Drive1_Change()
Dir1.Path = Drive1.Drive
End Sub
Private Sub Drive2_Change()
Dir2.Path = Drive2.Drive
End Sub

Private Sub Dir1_Change()
File1.Path = Dir1.Path
End Sub

Private Sub Dir2_Change()
Text2.Text = Dir2.Path
End Sub

Private Sub File1_Click()
Text1.Text = File1.Path & "\" & File1.FileName
End Sub

0 komentar:

Posting Komentar | Feed

Posting Komentar



 

jawe99 Copyright © 2009 Premium Blogger Dashboard Designed by SAER