/// <summary> /// Returns the current <see cref="TaskBarState"/> of the taskbar. /// </summary> public static TaskBarState GetState() { var data = new WinApi.AppBarData(); try { data.CbSize = (uint)Marshal.SizeOf(data); data.HWnd = WinApi.NativeMethods.FindWindow("System_TrayWnd", null); return((TaskBarState)WinApi.NativeMethods.SHAppBarMessage(WinApi.AppBarMessageOption.GetState, ref data)); } finally { data.Dispose(); } }
/// <summary> /// Sets the new <see cref="TaskBarState"/> of the taskbar. /// </summary> /// <param name="state"> /// The new state to set. /// </param> public static void SetState(TaskBarState state) { var data = new WinApi.AppBarData(); try { data.CbSize = (uint)Marshal.SizeOf(data); data.HWnd = WinApi.NativeMethods.FindWindow("System_TrayWnd", null); data.LParam = (int)state; WinApi.NativeMethods.SHAppBarMessage(WinApi.AppBarMessageOption.SetState, ref data); } finally { data.Dispose(); } }