公司的云桌面,影响到了原生系统的“拖动时显示窗体内容”,做了个处理程序。
感谢AI,现在查资料快速了许多。虽然的确有乱说的成分,但是庆幸的是大体思路没问题。
using System.Runtime.InteropServices;
// 检查当前设置
bool dragFullWindows = MsHelper.GetDragFullWindows();
Console.WriteLine("当前设置: " + (dragFullWindows ? "enable" : "disable"));
// 禁用拖动时显示窗口内容
MsHelper.ChangeDragFullWindows(false);
await Task.Delay(500);
MsHelper.ChangeDragFullWindows(true);
// 再次检查设置
dragFullWindows = MsHelper.GetDragFullWindows();
Console.WriteLine("更改后的设置: " + (dragFullWindows ? "enable" : "disable"));
// 启用拖动时显示窗口内容
//MsHelper.ChangeDragFullWindows(true);
//Console.ReadKey();
public static class MsHelper
{
[DllImport("user32.dll", SetLastError = true)]
public static extern bool SystemParametersInfo(uint uiAction, uint uiParam, ref bool pvParam, SPIF fWinIni);
//public const uint SPI_GETDRAGFULLWINDOWS = 0x0037;
//public const uint SPI_SETDRAGFULLWINDOWS = 0x0038;
public const uint SPI_GETDRAGFULLWINDOWS = 0x0026;
public const uint SPI_SETDRAGFULLWINDOWS = 0x0025;
public static bool GetDragFullWindows()
{
bool enabled = false;
SystemParametersInfo(SPI_GETDRAGFULLWINDOWS, 0, ref enabled, 0);
return enabled;
}
public static void ChangeDragFullWindows(bool enable)
{
SystemParametersInfo(SPI_SETDRAGFULLWINDOWS, enable ? 1u : 0, ref enable, SPIF.SPIF_SENDCHANGE);
}
}
[Flags]
public enum SPIF
{
SPIF_NONE = 0,
SPIF_SENDCHANGE = 0x2,
SPIF_UPDATEINIFILE = 0x1
}
标签:MsHelper,SPI,C#,uint,windows,SPIF,窗体,bool,public
From: https://www.cnblogs.com/3Tai/p/18137518