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