public static WINDOWPLACEMENT GetWindowPlacement(IntPtr handle)
 {
   // Persist window placement details to application settings
   var wp = new WINDOWPLACEMENT();
   GetWindowPlacement(handle, out wp);
   return wp;
 }
    public static void SetWindowPlacement(IntPtr handle, WINDOWPLACEMENT placement)
    {
      try
      {
        // Load window placement details for previous application session from application settings
        // Note - if window was closed on a monitor that is now disconnected from the computer,
        //        SetWindowPlacement will place the window onto a visible monitor.
        WINDOWPLACEMENT wp = placement;
        wp.length = Marshal.SizeOf(typeof(WINDOWPLACEMENT));
        wp.flags = 0;
        wp.showCmd = (wp.showCmd == SW_SHOWMINIMIZED ? SW_SHOWNORMAL : wp.showCmd);
        SetWindowPlacement(handle, ref wp);
      }
      catch { }

    }
 public static extern bool GetWindowPlacement(IntPtr hWnd, out WINDOWPLACEMENT lpwndpl);