I am very confused about what exactly the problem is or what you are trying to do but here are some topics to review in the help:
OpenProcess
GetExitCodeProcess

Like I said I am still confused so if this is far from what you are looking for oh well.