C # how to get processing on a specific window using user32 dll

How can I handle certain windows using user 32.dll? I work in C #. Thanks. Can someone give me a short example? :) I would appreciate it! (methods: getwindowtext, show window, enumwindowcallback normal).

+4
source share
1 answer

Try the following,

// For Windows Mobile, replace user32.dll with coredll.dll [DllImport("user32.dll", SetLastError = true)] static extern IntPtr FindWindow(string lpClassName, string lpWindowName); // Find window by Caption only. Note you must pass IntPtr.Zero as the first parameter. [DllImport("user32.dll", EntryPoint="FindWindow", SetLastError = true)] static extern IntPtr FindWindowByCaption(IntPtr ZeroOnly, string lpWindowName); // You can also call FindWindow(default(string), lpWindowName) or FindWindow((string)null, lpWindowName) 

EDIT: You can use this ad by following

  // Find window by Caption public static IntPtr FindWindow(string windowName) { var hWnd = FindWindow(windowName, null); return hWnd; } 

EDIT: 2 Here is a short version of the code:

  public class WindowFinder { // For Windows Mobile, replace user32.dll with coredll.dll [DllImport("user32.dll", SetLastError = true)] static extern IntPtr FindWindow(string lpClassName, string lpWindowName); public static IntPtr FindWindow(string caption) { return FindWindow(String.Empty, caption); } } 
+6
source

All Articles