Reputation: 78
I've basically copied the following code straight from the MSDN documentation:
#include <windows.h>
#include <stdio.h>
#pragma comment(lib, "user32.lib")
int main()
{
BOOL fResult;
int aMouseInfo[3]; // array for mouse information
// Get the current mouse speed.
fResult = SystemParametersInfo(
SPI_GETMOUSE, // get mouse information
0, // not used
&aMouseInfo, // holds mouse information
0); // not used
// Double it.
if( fResult )
{
aMouseInfo[2] = 1; // 2 * aMouseInfo[2];
// 1 should be a very noticeable change: slowing the cursor way down
// Change the mouse speed to the new value.
SystemParametersInfo(
SPI_SETMOUSE, // set mouse information
0, // not used
aMouseInfo, // mouse information
SPIF_SENDCHANGE); // update win.ini
}
return 0;
}
Yet when I run it, nothing seems to happen. The mouse speed should change, but it doesn't.
Windows Vista Home x32 (ouch) Dev-C++ Portable
Upvotes: 5
Views: 3254
Reputation: 949
Here , aMouseInfo[2] refers to Enhance Mouse Precision field. if aMouseInfo[2] is set to TRUE ( or assigned any no. other than 0 ), then Enhance Mouse Precision field is SET and if FALSE ( or assigned 0 ) then Enhance Mouse Precision field is UNSET .
For getting and setting the Mousespeed you can use SPI_GETMOUSESPEED and SPI_SETMOUSESPEED resp.
To use SPI_GETMOUSESPEED and SPI_SETMOUSESPEED , please refer to the post .
Upvotes: 3