how to get the current status(running or Dead) of a process at any time?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

hi
I wrote a class like this.......in my application.

public class cls
{
[DllImport("some.dll")]
[return : MarshalAs(UnmanagedType.Bool)]
public static extern bool myApp
(
[MarshalAs(UnmanagedType.LPStr)] ref string aa,
[MarshalAs(UnmanagedType.LPStr)] ref string bb,
[MarshalAs(UnmanagedType.I4)] ref int ProcessID,
[MarshalAs(UnmanagedType.I8)] ref long handle
);


public static int StartmyApp(string aa,string bb)/*this is function which calls the myapp*/
{
int processID = 0;
long handle = 0;
try
{
if(myApp(ref aa,ref bb,ref processID,ref handle))
{
nothing;
}
}
catch{ MessageBox.Show("Error in launching ");}

return processID;
}//end of function
}//end of cls class


problem description: myApp() is a function in a DLL which in turn starts a exe, myApp() function returns two values, they are processID and Handle of the exe or process started by that function.
Now i got to use the status of the process started by the above myApp() function, there are many places in my application where i need the status of the process whether the process is running or dead?.
How do i get the current status of the process at any time with latest information(live or dead)?

Hi tom walker and Willy Denoyette, have u got the clear picture of my problem

-------need HELP!
--------seash
 
try {
Process proc= Process.GetProcessById(processID );
// Do something usefull with proc
Console.WriteLine("Process: {0} still active"
,proc.ProcessName);
....
}
catch(System.ArgumentException e) {
// Process with Id xxxx is doesn't exist)
}

Willy.
 
BIG Thanks Willy
u r somuch helpful to ameature like me. can i have u r email id so that i can post my queries to u at first
thanks again
seash
 
Back
Top