Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Handler
- {
- // win native functions we have to load from user32.dll
- [DllImport("USER32.DLL", CharSet = CharSet.Unicode)]
- public static extern IntPtr FindWindow(String lpClassName, String lpWindowName);
- // win native functions we have to load from user32.dll
- [DllImport("USER32.DLL")]
- public static extern bool SetForegroundWindow(IntPtr hWnd);
- public static void bringToFront(string title)
- {
- // Get a handle to the application.
- IntPtr handle = FindWindow(null, title);
- // Verify that app is a running process.
- if (handle == IntPtr.Zero)
- {
- return;
- }
- // Make the appp the foreground application
- SetForegroundWindow(handle);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement