Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problems with OpenProcess

Status
Not open for further replies.

Craftor

Programmer
Feb 1, 2001
420
0
0
NZ
Hello again brainy people

I am using an app that calls the Shell command to open a program. It then gets a value returned from the Shell function and uses that to call the OpenProcess API. It then gets a return value by calling the WaitForSingleObject API. The thing is, I need to change the way this program is called - the user must be able to do some processing with the app called in the shell command. I can't find a lot of helpful info on MSDN on this so PLEASE HELP!!

Just let me know if this is too vague and you need the code. Help would REALLY be appreciated as this is quite urgent.

Thanks everyone!

Craftor
 
Hi Craftor,

The OpenProcess function is used usually, when you want your application to wait until the program that you called with the Shell function finishes.

It should look like this:

Private Const SYNCHRONIZED = &H100000
Private Const INFINITE = &HFFFFFFFF

Dim taskID As Long
Dim pTaskId As Long

taskID = Shell("Command line")
If taskID <> 0 Then
pTaskId = OpenProcess(SYNCHRONIZED, 0, taskID)
If pTaskId <> 0 Then
DoEvents
WaitForSingleObject pTaskId, INFINITE
CloseHandle pTaskId
DoEvents
End If
End If

I couldn't figure out exactly what's your problem (maybe you are missing the DoEvents?) - let me know if it helped or is the problem still there.

Regards,

Naftali.
 
Hi Naftali

Thanks but this did not solve the problem - I have found that it is a problem with the app I am calling in Shell. But thanks anyway!!!

Craftor
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top