According to the documentation for the SystemParametersInfo
and SPI_SETMOUSE
:
Sets two mouse thresholds and mouse acceleration. The pvParam
parameter must point to an array of three integers that sets these values. See mouse_event for more details.
So, you need an array containing 3 values, and you point to this array as the pvParam
parameter when calling SystemParametersInfo
.
Since all you care about is changing the acceleration (the last value), you probably want to keep the current values ββfor the first two values ββof the mouse threshold. Do this by calling SystemParametersInfo
with the SPI_GETMOUSE
flag to get these values, then changing the last (acceleration), and then calling SystemParametersInfo
again, this time with the SPI_SETMOUSE
flag.
Sample code (no recommendation for error checking):
// Turns mouse acceleration on/off by calling the SystemParametersInfo function. // When mouseAccel is TRUE, mouse acceleration is turned on; FALSE for off. void SetMouseAcceleration(BOOL mouseAccel) { int mouseParams[3]; // Get the current values. SystemParametersInfo(SPI_GETMOUSE, 0, mouseParams, 0); // Modify the acceleration value as directed. mouseParams[2] = mouseAccel; // Update the system setting. SystemParametersInfo(SPI_SETMOUSE, 0, mouseParams, SPIF_SENDCHANGE); }
And you probably already know this, but there are too many poorly managed applications so I don't mention it just in case. If you do this in your application, be sure to keep the original value to restore it when your application is closed! This is a simple basic etiquette when changing system-wide settings.
source share