home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 4_2005-2006.ISO / data / Zips / Accounting1980933172006.psc / Backup.bas < prev    next >
BASIC Source File  |  2006-03-18  |  3KB  |  102 lines

  1. Attribute VB_Name = "Backup"
  2. 'Public CompanyYear As String
  3. 'Public ZipFile As String
  4.  
  5. '***********************************************
  6. 'This Software is developed by craceinfotech.
  7. 'Web site : http://www.craceinfotech.com
  8. 'email    : craceinfotech.yahoo.com
  9. 'date     : 18.03.2006
  10. '***********************************************
  11.  
  12.     Private Type STARTUPINFO
  13.       cb As Long
  14.       lpReserved As String
  15.       lpDesktop As String
  16.       lpTitle As String
  17.       dwX As Long
  18.       dwY As Long
  19.       dwXSize As Long
  20.       dwYSize As Long
  21.       dwXCountChars As Long
  22.       dwYCountChars As Long
  23.       dwFillAttribute As Long
  24.       dwFlags As Long
  25.       wShowWindow As Integer
  26.       cbReserved2 As Integer
  27.       lpReserved2 As Long
  28.       hStdInput As Long
  29.       hStdOutput As Long
  30.       hStdError As Long
  31.    End Type
  32.  
  33.    Private Type PROCESS_INFORMATION
  34.       hProcess As Long
  35.       hThread As Long
  36.       dwProcessID As Long
  37.       dwThreadID As Long
  38.    End Type
  39.  
  40.    Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal _
  41.       hHandle As Long, ByVal dwMilliseconds As Long) As Long
  42.  
  43.    Private Declare Function CreateProcessA Lib "kernel32" (ByVal _
  44.       lpApplicationName As String, ByVal lpCommandLine As String, ByVal _
  45.       lpProcessAttributes As Long, ByVal lpThreadAttributes As Long, _
  46.       ByVal bInheritHandles As Long, ByVal dwCreationFlags As Long, _
  47.       ByVal lpEnvironment As Long, ByVal lpCurrentDirectory As String, _
  48.       lpStartupInfo As STARTUPINFO, lpProcessInformation As _
  49.       PROCESS_INFORMATION) As Long
  50.  
  51.    Private Declare Function CloseHandle Lib "kernel32" _
  52.       (ByVal hObject As Long) As Long
  53.  
  54.    Private Declare Function GetExitCodeProcess Lib "kernel32" _
  55.       (ByVal hProcess As Long, lpExitCode As Long) As Long
  56.  
  57.    Private Const NORMAL_PRIORITY_CLASS = &H20&
  58.    Private Const INFINITE = -1&
  59.  
  60.    Public Function ExecCmd(cmdline$)
  61.       Dim proc As PROCESS_INFORMATION
  62.       Dim start As STARTUPINFO
  63.       Dim RET As Long
  64.  
  65.       ' Initialize the STARTUPINFO structure:
  66.       start.cb = Len(start)
  67.  
  68.       ' Start the shelled application:
  69.       RET& = CreateProcessA(vbNullString, cmdline$, 0&, 0&, 1&, _
  70.          NORMAL_PRIORITY_CLASS, 0&, vbNullString, start, proc)
  71.  
  72.       ' Wait for the shelled application to finish:
  73.          RET& = WaitForSingleObject(proc.hProcess, INFINITE)
  74.          Call GetExitCodeProcess(proc.hProcess, RET&)
  75.          Call CloseHandle(proc.hThread)
  76.          Call CloseHandle(proc.hProcess)
  77.          ExecCmd = RET&
  78.    End Function
  79.  
  80. '   Sub Form_Click()
  81. '      Dim retval As Long
  82. '      'retval = ExecCmd("C:\Program Files\WinZip\WINZIP32.EXE -a d:\natarajan\test\backups\backup.zip @d:\natarajan\test\backups\filelist.txt")
  83. '      retval = ExecCmd("C:\Program Files\WinZip\WINZIP32.EXE -e d:\natarajan\test\backups\backup.zip d:\natarajan\test\backups\test")
  84. '      MsgBox "Process Finished, Exit Code " & retval
  85. '   End Sub
  86.  
  87. 'c:\progra~1\WinZip\winzip32 -a d:\natarajan\test\backups\backup.zip @d:\natarajan\test\backups\filelist.txt
  88. 'c:\progra~1\WinZip\winzip32 -e [options] filename[.zip] folder
  89. 'c:\progra~1\WinZip\winzip32 -e d:\natarajan\test\backups\backup.zip d:\natarajan\test\backups\TEST
  90.  
  91.  
  92.  
  93. 'Dim fLen As Integer, filepath As String
  94. 'filepath = "C:myfile.txt"
  95. 'On Error Resume Next
  96. 'fLen = Len(Dir$(filepath))
  97. 'If Err Or fLen = 0 Then
  98. ''file dosent exist
  99. 'Else
  100. ''file exists
  101. 'End If
  102.