|
-
Oct 27th, 2002, 11:00 PM
#1
Thread Starter
Hyperactive Member
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:
processID = Shell(App.Path & "\rar a " & rarName & ".rar " & "*.*", vbHide)
If processID <> 0 Then
procHandle = OpenProcess(0, 0, processID)
If procHandle <> 0 Then
rc = WaitForSingleObject(procHandle, 100)
Do While rc <> 0
rc = WaitForSingleObject(procHandle, 100)
DoEvents
Loop
CloseHandle (procHandle)
End If
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.
-
Oct 27th, 2002, 11:16 PM
#2
Hyperactive Member
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.
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
|