You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何通过WinAPI禁用Aero Shake但保留窗口停靠功能?

Disable Aero Shake via WinAPI While Keeping Window Snap Enabled

Great question! I’ve dealt with this exact issue before—using SPI_SETWINARRANGING is indeed too heavy-handed since it kills both Aero Shake and window snap. The trick is to target the specific registry setting that controls Aero Shake alone, just like the Group Policy Editor or manual Regedit changes do, but do it programmatically with WinAPI.

Here’s the step-by-step solution:

  • The registry key that controls Aero Shake (without affecting snap) is located at:
    HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced
  • The DWORD value DisallowShaking dictates whether Aero Shake is enabled:
    • Set it to 1 to disable Aero Shake
    • Set it to 0 to re-enable it

WinAPI Code Example (C++)

You can use the standard registry manipulation functions from WinAPI to modify this value, then notify Explorer to apply the changes immediately:

#include <windows.h>

BOOL DisableAeroShakePreserveSnap() {
    HKEY hAdvancedKey;
    // Open the target registry key
    LONG openResult = RegOpenKeyEx(HKEY_CURRENT_USER,
        L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced",
        0, KEY_SET_VALUE, &hAdvancedKey);

    if (openResult != ERROR_SUCCESS) {
        return FALSE;
    }

    // Set DisallowShaking to 1 (disable Aero Shake)
    DWORD shakeDisabled = 1;
    LONG setResult = RegSetValueEx(hAdvancedKey,
        L"DisallowShaking",
        0, REG_DWORD,
        (BYTE*)&shakeDisabled, sizeof(DWORD));

    RegCloseKey(hAdvancedKey);

    // Notify Windows Explorer to refresh settings (no restart needed)
    SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, 0,
        (LPARAM)L"Environment", SMTO_ABORTIFHUNG, 5000, nullptr);

    return setResult == ERROR_SUCCESS;
}

Key Notes:

  • Permissions: Modifying HKCU (Current User) settings only requires standard user privileges—no admin rights needed.
  • Immediate Effect: Sending the WM_SETTINGCHANGE message ensures Explorer picks up the change right away; you don’t have to restart the process.
  • No Snap Impact: This setting exclusively controls Aero Shake. Window snap (the docking feature) is governed by separate registry keys and system parameters, so it will continue working normally.

If you ever need to re-enable Aero Shake, just change shakeDisabled to 0 and run the same logic.

内容的提问来源于stack exchange,提问作者Evgeniy Kozlov

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.27 03:26:01