View Single Post

  #7 (permalink)  
Old 05-04-2007
Marin Marin is offline
Junior Member
White Belt
 
Join Date: Apr 2007
Posts: 6
Re: Finding MapPoint process

Quote:
Originally Posted by Wilfried View Post
Hi,

I'm not sure.

Code:
Process[] processes = Process.GetProcessesByName("MapPoint");
foreach (Process proc in processes)
    if (proc.Handle == app)
But I'm not sure if the handle of the process is the same as the value of app. It can be the address of it. So if not I'm stuck as well.
proc.Handle and app are not comparable types so this can't work.

So, maybe, this workaround is the best that can be done.
Code:
Process thisProcess = Process.GetCurrentProcess();
app.Caption = thisProcess.Id.ToString();
Process[] procesi = Process.GetProcessesByName("MapPoint");
foreach (Process p in procesi)
{
    if (p.MainWindowTitle == "Map - "+thisProcess.Id.ToString())
    {
        //p is the one
    }
}
Can it be done easier?
Reply With Quote