DeafBug
September 28th, 2001, 11:31 AM
Hi,
I have done a search in this forum and I found everything I need. But one thing that I am concern about is the ProcessID. I am not too familiar with how they work. I know it is unique. I did a bunch of testing over time (without rebooting) and I did come across with the SAME processID used earlier. The question I have is "Is there a way to find out the name of the application based on the ProcessID?" I have not found an answer for it in this forum.
What I am doing is calling several external applications that we developed from the main program that we also developed. In other words one parent program and a number of child programs. Yes, we did code that the program can't be run from stand-alone and must be within the parent program (via command parameters) so it will always be launched from the parent program.
Now I have successfully added a bunch of API calls to launch and terminate the process (child program) within the parent program. Whenever a child is launch I save the ProcessID for that child. When the user wants to close the parent program, all child programs are killed first before parent unloads.
As I mentioned before that I did had a same ProcessID used twice. I want to know if there is a way to find out, the name of the external child program based on the ProcessID I had saved when it first launched. The reason I ask this is because I don't want to kill a process if it is not the child program of the parent. (If the user closed the child program and then opens Word which has the same processID that the child had.) I don't want to upset the users by closing a third-party program simply because the processID matched. I need a little more validation which would be the name of the application.
One thing, I should mention. All of our child programs can be running one instance. If they try to open a second instance, it brings up the first instance (code off from MS KB)
So I feel that it is foolproof that if I can match the ProcessID with the name of the program before terminating the process.
Any API calls I can use. Each one of them is individual and can be switched. Don't want to use the WaitForSingleObject or eat up CPU cycles. Just a simple check when the parent is unloading.
I have done a search in this forum and I found everything I need. But one thing that I am concern about is the ProcessID. I am not too familiar with how they work. I know it is unique. I did a bunch of testing over time (without rebooting) and I did come across with the SAME processID used earlier. The question I have is "Is there a way to find out the name of the application based on the ProcessID?" I have not found an answer for it in this forum.
What I am doing is calling several external applications that we developed from the main program that we also developed. In other words one parent program and a number of child programs. Yes, we did code that the program can't be run from stand-alone and must be within the parent program (via command parameters) so it will always be launched from the parent program.
Now I have successfully added a bunch of API calls to launch and terminate the process (child program) within the parent program. Whenever a child is launch I save the ProcessID for that child. When the user wants to close the parent program, all child programs are killed first before parent unloads.
As I mentioned before that I did had a same ProcessID used twice. I want to know if there is a way to find out, the name of the external child program based on the ProcessID I had saved when it first launched. The reason I ask this is because I don't want to kill a process if it is not the child program of the parent. (If the user closed the child program and then opens Word which has the same processID that the child had.) I don't want to upset the users by closing a third-party program simply because the processID matched. I need a little more validation which would be the name of the application.
One thing, I should mention. All of our child programs can be running one instance. If they try to open a second instance, it brings up the first instance (code off from MS KB)
So I feel that it is foolproof that if I can match the ProcessID with the name of the program before terminating the process.
Any API calls I can use. Each one of them is individual and can be switched. Don't want to use the WaitForSingleObject or eat up CPU cycles. Just a simple check when the parent is unloading.