Mouse speed not changing by using SPI_SETMOUSESPEED

前端 未结 1 626
旧时难觅i
旧时难觅i 2021-01-25 09:27

Why mouse speed is not changing after execution of the following program ?

Is it due to SPI_SETMOUSESPEED or due to unable to change the winini<

1条回答
  •  醉话见心
    2021-01-25 09:36

    You are passing the wrong value as pvParam for SPI_SETMOUSESPEED. From the documentation:

    Sets the current mouse speed. The pvParam parameter is an integer between 1 (slowest) and 20 (fastest). A value of 10 is the default. This value is typically set using the mouse control panel application.

    Compare that to the documentation for SPI_GETMOUSESPEED

    Retrieves the current mouse speed. The mouse speed determines how far the pointer will move based on the distance the mouse moves. The pvParam parameter must point to an integer that receives a value which ranges between 1 (slowest) and 20 (fastest). A value of 10 is the default. The value can be set by an end-user using the mouse control panel application or by an application using SPI_SETMOUSESPEED.

    So for SPI_GETMOUSESPEED you must pass an int* value as pvParam, but for SPI_SETMOUSESPEED you must pass in int value. You are passing an int* in both cases. Your call for SPI_SETMOUSESPED should be:

    SystemParametersInfo(
        SPI_SETMOUSESPEED,
        0,
        (LPVOID) newMouseSpeed,
        SPIF_UPDATEINIFILE | SPIF_SENDCHANGE | SPIF_SENDWININICHANGE
    );
    

    0 讨论(0)
提交回复
热议问题