Windows API相关,常用于P/Invoke
SystemParametersInfo
检索或设置某个系统范围参数的值。此功能还可以在设置参数时更新用户配置文件。
SystemParametersInfoW function (winuser.h)
以编程方式更新桌面“拖动时显示窗口内容”设置
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
}
参考:Update desktop "show window contents while dragging" setting programatically