问题
I am trying to disable all the visual effects within a Windows Server 2012 R2 remote desktop session. This is normally getting done via System => Advanced system settings => Performance "Settings" and apply the "adjust for best performance" preset.
As there are no group-policy settings nor registry values that can be set I stumbled of SystemParamtersInfo function. Unfortunately it has absolutly no effect on the RDP session I am testing it in.
I am no good programmer and this is what I knit together, with MSDN and google's help.
namespace SetVisualEffects
{
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
public class SetVisualEffects
{
[DllImport("user32.dll", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool SystemParametersInfo(uint uiAction, uint uiParam, bool pvParam, uint fWinIni);
private static UInt32 SPI_SETUIEFFECTS = 0x103F;
private static UInt32 SPI_SETFONTSMOOTHING = 0x004b;
private static UInt32 SPI_SETDROPSHADOW = 0x1025;
public static void Main()
{
SystemParametersInfo(SPI_SETDROPSHADOW, 0, false, 0);
SystemParametersInfo(SPI_SETUIEFFECTS, 0, false, 0);
SystemParametersInfo(SPI_SETFONTSMOOTHING, 0, false, 0);
}
}
}
And my similar approach using C++, unfortunately with the same outcome.
#include <windows.h>
#include <stdio.h>
#include <iostream>
#pragma comment(lib, "user32.lib")
int main()
{
// Disables all UI effects.
SystemParametersInfo(SPI_SETUIEFFECTS, 0, FALSE, SPIF_SENDCHANGE);
// Disables "Animate controls and elements inside windows"
// Disables "Animate windows when minimizing and maximizing"
// Disables "Animations in the taskbar"
// Disables "Enable Peek"
// Disables "Fade or slide menus into view"
SystemParametersInfo(SPI_SETMENUANIMATION, 0, FALSE, SPIF_SENDCHANGE);
SystemParametersInfo(SPI_SETMENUFADE, 0, FALSE, SPIF_SENDCHANGE);
// Disables "Fade or slide ToolTips into view"
SystemParametersInfo(SPI_SETTOOLTIPFADE, 0, FALSE, SPIF_SENDCHANGE);
// Disables "Fade out menu items after clicking"
SystemParametersInfo(SPI_SETSELECTIONFADE, 0, FALSE, SPIF_SENDCHANGE);
// Disables "Save taskbar thumbnail previews"
// Disables "Show shadows under mouse pointer"
SystemParametersInfo(SPI_SETCURSORSHADOW, 0, FALSE, SPIF_SENDCHANGE);
// Disables "Show shadows under windows"
// Disables "Show thumbnails instead of icons"
// Disables "Show translucent selection rectangle"
// Disables "Show window contents while dragging"
// Disables "Slide open combo boxes"
SystemParametersInfo(SPI_SETCOMBOBOXANIMATION, 0, FALSE, SPIF_SENDCHANGE);
// Disables "Smooth edges of screen fonts"
SystemParametersInfo(SPI_SETFONTSMOOTHING, 0, FALSE, SPIF_SENDCHANGE);
// Disables "Smooth-scroll list boxes"
SystemParametersInfo(SPI_SETLISTBOXSMOOTHSCROLLING, 0, FALSE, SPIF_SENDCHANGE);
// Disables "Use drop shadows for icon labels on the desktop"
SystemParametersInfo(SPI_SETDROPSHADOW, 0, FALSE, SPIF_SENDCHANGE);
return 0;
}
So what am I doing wrong here?
来源:https://stackoverflow.com/questions/25237231/disable-visual-effects-call-to-systemparamtersinfo-shows-no-effect