public static void SaveFormPlacement(RegistryKey key, Form form, string name)
 {
     if (form.WindowState == FormWindowState.Normal)
       {
     key.SetRectangleValue(name, form.DesktopBounds);
       }
       else
       {
     Rectangle workingArea = Screen.PrimaryScreen.WorkingArea;
     Rectangle restoreBounds = form.RestoreBounds;
     restoreBounds.X -= workingArea.X;
     restoreBounds.Y -= workingArea.Y;
     key.SetRectangleValue(name, restoreBounds);
       }
       key.SetWindowStateValue(name, form.WindowState);
 }