Is there a way to get the window handle (IntPtr) for a window after its launched from a C# app with Process.Start()?
+6
A:
If it's the main window you're after, Process.MainWindowHandle
will give you what you need.
Noldorin
2009-09-14 12:14:23
+3
A:
Use
process.MainWindowHandle;
It probably is 0 when launching the app, so you might want to loop and sleep until it is filled up.
Jan Jongboom
2009-09-14 12:15:35
Hi Jan,For me, the handle is always zero and never goes to any other value, even after infinite looping. I use the following code:proc.StartInfo.FileName = @"C:\Documents and Settings\SUM\Desktop\PortableApps\Notepad++Portable\Notepad++Portable.exe"; proc.StartInfo.Arguments = String.Empty; proc.Start(); IntPtr appHwnd = proc.MainWindowHandle; while (appHwnd == IntPtr.Zero) { Thread.Sleep(100); appHwnd = proc.MainWindowHandle; }What's wrong?
Marcel
2010-01-04 09:55:10
Marcel
2010-01-04 10:23:39
+1
A:
You could also call Refresh() on the process to be sure the info in accurate
Tristan
2009-09-14 13:05:22