-----------------------------------------------------------

New Message on BDOTNET

-----------------------------------------------------------
From: Sitaraman
Message 3 in Discussion

Hi Arshad : guess GetExitCodeProcess will be a problem, coz u need to pass a process 
handle to it as the first parameter .  This is suitable when u urself start a 
process.That is  lets say    a. Start a process b. Get the Process Id(DWord) of the 
Task c. Call "OpenProcess" function passing the Process Id as the 3rd parameter d. Get 
the process handle which is returned e. Use GetExitCodeProcess  passing the acquired 
handle as the first parameter and then get the ExitCodein the byref variable passed as 
the 2nd parameter f. Then u can check whether the app is STILL_ACTIVE(&H103&)   Here 
how will u get the processhandle(or for that matter processid, to start with)   I 
think, what Mudassir needs is a capability to find an app started by the user from any 
option and not explicitly by the calling program.  For that u can use the processinfo 
class(u had only posted this code on 9 july for a query by RaviKumar :) ). I have 
changed it a little and CCPed MSDN code and is as follows   Imports System
Imports System.Diagnostics
Imports Microsoft.VisualBasic Class GetProcessesByNameClass     ' To test this app, do 
the folowing
    ' 1. Close all notepad instances on ur machine(if any) 
    ' 2. run this app
    ' 3. Type your machine name at the command prompt "Enter Machine Name : "
    ' 4. Type notepad   at the command prompt   "Enter application Name : "
    ' ----- It will give the message "Could not find notepad processes on machine : 
XXXXXX"
    ' 5. Start notepad from com,mand prompt/start menu
    ' 6. Repeat steps 2 and 3 and 4
    ' ----- It will give the message "Process Name : notepad  Process ID : nnnn  
MachineName : XXXXXX"     Public Overloads Shared Sub Main(ByVal args() As String)
        Try
            Console.WriteLine("Check processes on any Machine ")
            Console.Write("Enter Machine Name : ")
            Dim MachineName As String = Console.ReadLine()
            Console.Write("Enter application Name : ")
            Dim appname As String = Console.ReadLine()             ' Get all notepad 
processess into Process array.
            Dim myProcesses As Process() = Process.GetProcessesByName _
                                                (appname, MachineName)
            If myProcesses.Length = 0 Then
                Console.WriteLine("Could not find notepad processes on machine : " & 
MachineName)
            End If
            Dim myProcess As Process
            For Each myProcess In myProcesses
                Console.WriteLine("Process Name : " & myProcess.ProcessName & _
                              "  Process ID : " & myProcess.Id & _
                              "  MachineName : " & myProcess.MachineName)
            Next myProcess         Catch e As SystemException
            Console.Write("Caught Exception .... : " & e.Message)
        Catch e As Exception
            Console.Write("Caught Exception .... : " & e.Message)
        End Try
        Console.ReadLine()
    End Sub 'Main
End Class 'GetProcessesByNameClass
   hth     regards,   sr

-----------------------------------------------------------

To stop getting this e-mail, or change how often it arrives, go to your E-mail 
Settings.
http://groups.msn.com/BDotNet/_emailsettings.msnw

Need help? If you've forgotten your password, please go to Passport Member Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help

For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact

If you do not want to receive future e-mail from this MSN group, or if you received 
this message by mistake, please click the "Remove" link below. On the pre-addressed 
e-mail message that opens, simply click "Send". Your e-mail address will be deleted 
from this group's mailing list.
mailto:[EMAIL PROTECTED]

Reply via email to