Advertisement
Guest User

Untitled

a guest
Jul 12th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.82 KB | None | 0 0
  1.    class Handler
  2.     {
  3.         // win native functions we have to load from user32.dll
  4.         [DllImport("USER32.DLL", CharSet = CharSet.Unicode)]
  5.         public static extern IntPtr FindWindow(String lpClassName, String lpWindowName);
  6.  
  7.         // win native functions we have to load from user32.dll
  8.         [DllImport("USER32.DLL")]
  9.         public static extern bool SetForegroundWindow(IntPtr hWnd);
  10.  
  11.         public static void bringToFront(string title)
  12.         {
  13.             // Get a handle to the application.
  14.             IntPtr handle = FindWindow(null, title);
  15.  
  16.             // Verify that app is a running process.
  17.             if (handle == IntPtr.Zero)
  18.             {
  19.                 return;
  20.             }
  21.  
  22.             // Make the appp the foreground application
  23.             SetForegroundWindow(handle);
  24.         }
  25.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement