|
-
Jun 29th, 2005, 08:44 AM
#1
Thread Starter
Junior Member
Alternative to shell.application.shellexecute
Hi
I'm trying to write a piece of code that will zip a file to a winrar archive and then email the archive. I'm currently using shellexecute, but this is asynchronous it kicks off the command "winrar a file.txt archive.rar" and then moves to the next command. Whereas I wish to wait for the rar file to be created before I attach the file and send my email message.
Does anyone have an alternative ?
-
Jul 5th, 2005, 01:41 PM
#2
Re: Alternative to shell.application.shellexecute
Separate the two into two different click events.
-
Jul 6th, 2005, 05:29 AM
#3
Thread Starter
Junior Member
Re: Alternative to shell.application.shellexecute
Hi Hack,
Sorry I should have replied to this. I was actually trying to achieve this in an VB activex/dll. I've actually managed to do it using windows API
VB Code:
Private Declare Function FindExecutable Lib "shell32.dll" Alias _
"FindExecutableA" (ByVal lpFile As String, ByVal lpDirectory As String, _
ByVal lpResult As String) As Long
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
Const SYNCHRONIZE As Long = &H100000
Const INFINITE As Long = &HFFFFFFFF
Public Sub ShellAndWait(ByVal program_name As String, ByVal window_style As VbAppWinStyle)
Dim process_id As Long
Dim process_handle As Long
Dim lngdb As Long
' Start the program.
process_id = Shell(program_name, window_style)
'process_id = ShellExecute(Me.hWnd, "open", program_name, vbNullString, App.Path, 1)
' Wait for the program to finish.
' Get the process handle.
process_handle = OpenProcess(SYNCHRONIZE, 0, process_id)
If process_handle <> 0 Then
WaitForSingleObject process_handle, INFINITE
CloseHandle process_handle
End If
End Sub
Thanks
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|