tags:

views:

85

answers:

1

I want to create a process in Win32 .NET can I determine FOR the OS which PID the application will get ?

Update:

1) I am asking it because I have a problem in which I have 2 .NET application (the same ones) that I have each one of them got parameter ID and I want using a script (using the parameter) to decide which is the one and get it's PID 2) I want to know it from out side not from the .NET Process. I need for a script

+6  A: 

You can never determine what PID a process will get. You can only determine what PID a process did get after you start the process.

In .Net you can do the following

var newProcess = Process.Start(someExeFile);
var id = newProcess.Id

In Win32 the CreateProcess function will return an PROCESS_INFORMATION struct as an out parameter of the function. It has the new PID as one of it's members (dwProcessId)

JaredPar
Yes as I suspected. I am asking it because I have a problem in which I have 2 .NET application (the same ones) that I have each one of them got parameter ID and I want using a script (using the parameter) to decide which is the one and get it's PID.
Roman Dorevich
Yes but I want to know it from out side not from the .NET Process.I need for a script.
Roman Dorevich