I just cut this out of an older compression development progr of mine(in
VB) but it will give you the general idea.
Const SYNCHRONIZE = &H100000
Const INFINITE = &HFFFF
'Wait forever
Const WAIT_OBJECT_0 = 0
'The state of the specified object is signaled
Const WAIT_TIMEOUT = &H102
'The time-out interval elapsed & the object's state
'is nonsignaled.
Private Declare Function OpenProcess Lib "kernel32" (ByVal
dwDesiredAccess As Long, _
ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As
Long
Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal
hHandle As Long, _
ByVal dwMilliseconds As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As
Long) As Long
Private Declare Sub CopyMem Lib "kernel32" Alias "RtlMoveMemory" _
(Destination As Any, Source As Any, ByVal Length As Long)
Private Function RunZip(fname As String, ctr As Long)
Dim lPid As Long
Dim lHnd As Long
Dim lRet As Long
Dim lngTemp As Long
Dim s As String
Dim s1 As String
Dim level As Long
s = "C:\Program Files\Winzip\wzzip.exe -a -ex -ybc "
s1 = s & ctr & "Level" & ".zip" & " " & fname
lPid = Shell(s1, vbHide) ' vbNormalFocus) ' vbhide
If lPid <> 0 Then
'Get a handle to the shelled process.
lHnd = OpenProcess(SYNCHRONIZE, 0, lPid)
'If successful, wait for the application to end and close the
handle.
If lHnd <> 0 Then
lRet = WaitForSingleObject(lHnd, INFINITE)
CloseHandle (lHnd)
End If
'MsgBox "Just terminated.", vbInformation, "Shelled Application"
End If
RunZip = ctr & "Level" & ".zip"
' *********************************************************
' DEBUG.. PUT THIS BACK IN!!!!!!!!!!!!
' no looked after in calling function
Kill fname
'Debug.Print "Level:" & ctr
Dim strTemp As String
Dim ZipFileLength As Long
ZipFileLength = FileLen(ctr & "Level" & ".zip")
strTemp = ""
strTemp = strTemp & "ZIP FileName:" & ctr & "Level" & vbTab & vbTab &
"Size:" & vbTab & ZipFileLength & vbCrLf
strTemp = strTemp & "---------------------------------------------" &
vbCrLf
strTemp = strTemp & "Savings:" & OrigFileLength & vbTab & "-" &
ZipFileLength & vbTab & "=" & vbTab & vbTab & OrigFileLength -
ZipFileLength & vbCrLf
strTemp = strTemp & "*********************************************" &
vbCrLf
'strTemp = strTemp & vbCrLf
'strTemp = strTemp & "Highest Reps:" & lngHigh & vbCrLf
Me.txtLog.Text = Me.txtLog.Text & strTemp
Me.txtSummary.Text = ctr & "Level" & ".zip"
End Function
--
HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.