Results 1 to 3 of 3

Thread: Alternative to shell.application.shellexecute

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jun 2002
    Posts
    31

    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 ?

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Alternative to shell.application.shellexecute

    Separate the two into two different click events.

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jun 2002
    Posts
    31

    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:
    1. Private Declare Function FindExecutable Lib "shell32.dll" Alias _
    2. "FindExecutableA" (ByVal lpFile As String, ByVal lpDirectory As String, _
    3. ByVal lpResult As String) As Long
    4.  
    5.  
    6. Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess _
    7. As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
    8.  
    9. Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle _
    10. As Long, ByVal dwMilliseconds As Long) As Long
    11.  
    12. Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
    13.  
    14. Const SYNCHRONIZE As Long = &H100000
    15. Const INFINITE As Long = &HFFFFFFFF
    16.  
    17.  
    18. Public Sub ShellAndWait(ByVal program_name As String, ByVal window_style As VbAppWinStyle)
    19. Dim process_id As Long
    20. Dim process_handle As Long
    21. Dim lngdb  As Long
    22.  
    23.     ' Start the program.
    24.     process_id = Shell(program_name, window_style)
    25.     'process_id = ShellExecute(Me.hWnd, "open", program_name, vbNullString, App.Path, 1)
    26.  
    27.  
    28.     ' Wait for the program to finish.
    29.     ' Get the process handle.
    30.     process_handle = OpenProcess(SYNCHRONIZE, 0, process_id)
    31.     If process_handle <> 0 Then
    32.         WaitForSingleObject process_handle, INFINITE
    33.         CloseHandle process_handle
    34.     End If
    35.  
    36. 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
  •  



Click Here to Expand Forum to Full Width