I'm trying to find the handle of the main thread of an external application. The program I am trying to find the main thread of is multithreaded and it is important I always find the main thread. I know that at most there will be one copy of this program running. This is how I am doing it at the moment:
Process[] someProcesses = Process.GetProcessesByName("some");
IntPtr threadHandle = OpenThread(ThreadAccess.SUSPEND_RESUME, false, (uint)someProcesses[0].Threads[0].Id);
Most of the time, Threads[0] is the main thread but other times it is not. How can I make sure that the thread that I find is the main thread of the other application?
Thankyou.