This works for me (Windows 10 22H2) :
BOOL bRendering = FALSE;
// returns TRUE
HRESULT hr = DwmGetWindowAttribute(hWnd, DWMWA_NCRENDERING_ENABLED, &bRendering, sizeof(bRendering));
// Disable
DWMNCRENDERINGPOLICY ncrp = DWMNCRP_DISABLED;
hr = DwmSetWindowAttribute(hWnd, DWMWA_NCRENDERING_POLICY, &ncrp, sizeof(ncrp));
// returns FALSE
hr = DwmGetWindowAttribute(hWnd, DWMWA_NCRENDERING_ENABLED, &bRendering, sizeof(bRendering));