public static string GetPlacement(IntPtr windowHandle) { WINDOWPLACEMENT placement = new WINDOWPLACEMENT(); GetWindowPlacement(windowHandle, out placement); using (MemoryStream memoryStream = new MemoryStream()) { using (XmlTextWriter xmlTextWriter = new XmlTextWriter(memoryStream, Encoding.UTF8)) { serializer.Serialize(xmlTextWriter, placement); byte[] xmlBytes = memoryStream.ToArray(); return encoding.GetString(xmlBytes); } } }
private static extern bool GetWindowPlacement(IntPtr hWnd, out WINDOWPLACEMENT lpwndpl);