Results 1 to 2 of 2

Thread: Shell, And not continuing until its finished

  1. #1

    Thread Starter
    Hyperactive Member Blinky Bill's Avatar
    Join Date
    Mar 2002
    Location
    Happily munching on the greenery in your garden
    Posts
    349

    Shell, And not continuing until its finished

    Hi Guys,
    I need to run an external program from my app, and i need to wait for it to finish before continuing the processing in my app. I posted a question on this last week and i got the following code

    VB Code:
    1. processID = Shell(App.Path & "\rar a " & rarName & ".rar " & "*.*", vbHide)
    2.    
    3.     If processID <> 0 Then
    4.         procHandle = OpenProcess(0, 0, processID)
    5.         If procHandle <> 0 Then
    6.             rc = WaitForSingleObject(procHandle, 100)
    7.             Do While rc <> 0
    8.                 rc = WaitForSingleObject(procHandle, 100)
    9.                 DoEvents
    10.             Loop
    11.             CloseHandle (procHandle)
    12.         End If
    13.     End If

    Now, this code is supposed to get the processID of the shell command and wait for it to be released and then let me continue. This code works on my computer fine (Win XP), but when i run it on a Win2K machine, the program never leaves this loop.

    Is there something wrong with this code, or is it something to do with having different numbers of apps running at the same time?

    I need to get this to work on Win98+ quickly, so if anyone can see why this doesn't work, or has an alternative that does what i want then i'll be very greatful.

    Thanx all in advance.
    We don't know what's wrong. . . So the best bet might be to remove something surgically.

  2. #2
    Hyperactive Member ravi15481's Avatar
    Join Date
    Aug 2002
    Location
    INDIA
    Posts
    421
    just check out what does WaitForSingleObject returns, it could be any of the follwing:-

    If the function fails, the return value is WAIT_FAILED. To get extended error information, call GetLastError.

    The return value on success is one of the following values:
    WAIT_ABANDONED
    The specified object is a mutex object that was not released by the thread that owned the mutex object before the owning thread terminated. Ownership of the mutex object is granted to the calling thread, and the mutex is set to nonsignaled.

    WAIT_OBJECT_0
    The state of the specified object is signaled.

    WAIT_TIMEOUT
    The time-out interval elapsed, and the object’s state is nonsignaled.
    A good friend...

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