Results 1 to 5 of 5

Thread: Shell an app

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2000
    Posts
    617
    When I shell an app, how can I tell when it's completed?

    Thanks in advance

  2. #2
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    Code:
    this is the code for trythis.exe
    
    Private Sub Form_Load()
        Dim x As Integer, y As Integer
        Randomize
        For x = 1 To 4000
          y = x * Int(Rnd * 10) + 1
        Next x
        Unload Me
    End Sub
    
    'this is the code for Project1
    
    Private Sub Command1_Click()
      Shell ("C:\myApp.exe")
      DoEvents
      MsgBox "Done"
    End Sub
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2000
    Posts
    617

    Thanks (But)

    You know.. I am shelling a DOS prog... (not my prog) to uncompress a set of files... I have no know way of knowing
    when the uncompress is done so that I can proceed with
    files resulting from the uncompress...

    My prog needs to know that...

    Hope I am a bit clearer...

    Any help is appreciated


  4. #4
    Guest
    Try this:

    Code:
    Private Declare Function OpenProcess Lib "Kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
    Private Declare Function GetExitCodeProcess Lib "Kernel32" (ByVal hProcess As Long, lpExitCode As Long) As Long
    Private Declare Sub Sleep Lib "Kernel32" (ByVal dwMilliseconds As Long)
    Const STILL_ACTIVE = &H103
    Const PROCESS_QUERY_INFORMATION = &H400
    
    'JobtoDo - Program to run
    'frm - Form
    'You can do anything after the loop..shell another program if that program is close, load another version of your app, etc.
    
    Sub Shell32Bit(ByVal JobToDo As String, frm As Form)
    
             Dim hProcess As Long
             Dim RetVal As Long
             'The next line launches JobToDo as icon,
    
             'captures process ID
             hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, False, Shell(JobToDo, 1))
    
             Do
    
                 'Get the status of the process
                 GetExitCodeProcess hProcess, RetVal
    
                 'Sleep command recommended as well as DoEvents
                 DoEvents: Sleep 100
    
             'Loop while the process is active
             Loop While RetVal = STILL_ACTIVE 
             'Put your code here
             'Events here occur when app is unloaded
    End Sub
    
    Usage:
    
    Private Sub Command1_Click()
    Call Shell32Bit("C:\App\App.exe", Me)
    End Sub

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2000
    Posts
    617

    !!!!

    Wow!

    Matthew.... That's quite a piece..!

    It looks very promising... I will try first, God willing,
    first thing tomorrow morning


    Thanks a lot...

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