VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Compresses or uncompresses (depending on which procedure you call) a file using the WinRAR DOS Exec

by Programming Innovations (7 Submissions)
Category: Miscellaneous
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Mon 19th August 2002
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Compresses or uncompresses (depending on which procedure you call) a file using the WinRAR DOS Executables. NOTE: Send me an email for a copy

API Declarations


' Constants
Global Const STILL_ACTIVE = &H103
Global Const PROCESS_QUERY_INFORMATION = &H400

' Vars
Global gsRARPath As String
Global gsUnRARPath As String

' Declares
Declare Function OpenProcess Lib "Kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Declare Function GetExitCodeProcess Lib "Kernel32" (ByVal hProcess As Long, lpExitCode As Long) As Long

Rate Compresses or uncompresses (depending on which procedure you call) a file using the WinRAR DOS Exec



    Dim lRetVal As Long
    Dim hProcess As Long
    Dim sCommandLine As String
    Dim fso As New Scripting.FileSystemObject
    
    If fso.FileExists(CreateFullPath(sArchive, sNewPath)) = True Then
        fso.DeleteFile CreateFullPath(sArchive, sNewPath), True
    End If
    DoEvents
    
    sCommandLine = """" & gsRARPath & """ a -r """ & CreateFullPath(sArchive, sNewPath) & """ """ & sFile & """"
    Debug.Print sCommandLine
    
    If sCommandLine <> "" Then
        hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, False, Shell(sCommandLine, vbHide))
        
        Do
          GetExitCodeProcess hProcess, lRetVal
          DoEvents
        Loop While lRetVal = STILL_ACTIVE
    End If
End Sub
Sub UNZIPFiles(sFileName As String, sNewPath As String)
    Dim lRetVal As Long
    Dim hProcess As Long
    Dim sCommandLine As String
        
    sCommandLine = """" & CreateFullPath("unrar.exe", App.Path) & """ e -o+ """ & sFileName & """ """ & sNewPath & """" '..\unrar.exe e update.rar ..\temp"
    
    If sCommandLine <> "" Then
        hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, False, Shell(sCommandLine, vbHide))
        
        Do
          GetExitCodeProcess hProcess, lRetVal
          DoEvents
        Loop While lRetVal = STILL_ACTIVE
    End If
End Sub

Download this snippet    Add to My Saved Code

Compresses or uncompresses (depending on which procedure you call) a file using the WinRAR DOS Exec Comments

No comments have been posted about Compresses or uncompresses (depending on which procedure you call) a file using the WinRAR DOS Exec. Why not be the first to post a comment about Compresses or uncompresses (depending on which procedure you call) a file using the WinRAR DOS Exec.

Post your comment

Subject:
Message:
0/1000 characters