3 Replies - 731 Views - Last Post: 15 January 2013 - 05:29 AM Rate Topic: -----

#1 mdockz  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 07-January 13

using PID in getprocessbyid

Posted 09 January 2013 - 07:39 PM

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");
                }                
            }
        }


Is This A Good Question/Topic? 0
  • +

Replies To: using PID in getprocessbyid

#2 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5535
  • View blog
  • Posts: 11,861
  • Joined: 02-June 10

Re: using PID in getprocessbyid

Posted 09 January 2013 - 07:45 PM

View Postmdockz, on 09 January 2013 - 08:39 PM, said:

I have multiple applications open with the same exe name but different window titles.


Why? WTF?
Was This Post Helpful? 0
  • +
  • -

#3 b0zhidar  Icon User is offline

  • New D.I.C Head

Reputation: 4
  • View blog
  • Posts: 24
  • Joined: 21-December 12

Re: using PID in getprocessbyid

Posted 14 January 2013 - 08:14 PM

View PosttlhIn`toq, on 09 January 2013 - 07:45 PM, said:

View Postmdockz, on 09 January 2013 - 08:39 PM, said:

I have multiple applications open with the same exe name but different window titles.


Why? WTF?

Maybe he's using Chrome?
From my knowledge Chrome is starting multiple processes by name "chrome.exe" for each tab.
If I am not mistaken.
Was This Post Helpful? 0
  • +
  • -

#4 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 3589
  • View blog
  • Posts: 11,165
  • Joined: 05-May 12

Re: using PID in getprocessbyid

Posted 15 January 2013 - 05:29 AM

Same for notepad.exe.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1