Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

using PID in getprocessbyid

$
0
0
I know how the function works, so I dont need anyone to explain it to me. However, I have multiple applications open with the same exe name but different window titles. I use this code to find the PID based on the window title. Now how do use this with getprocessbyid? Or since it is already returning only the pid from that specific window title, is what im asking unnecessary?

private void function1()
        {
            Process[] processlist = Process.GetProcessesByName("my process");

            string title = "title";
            string procID;
            
            foreach (Process process in processlist)
            {
                if (String.Equals(process.MainWindowTitle, title))
                {
                    procID = process.Id.ToString();
                    MessageBox.Show("This is the process ID: " + process.Id);
                    MessageBox.Show(procID);
                }
                else
                {
                    MessageBox.Show("Window not found");
                }                
            }
        }

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>