locked
Cannot disable Mouse Sonar using SystemParametersInfo with SPI_SETMOUSESONAR RRS feed

  • Question

  • Hello everyone,

    I am currently trying to enable/disable the Mouse Sonar feature using my app.

    Based on MSDN's reference article, I am supposed to do this using SystemParametersInfo function.

    I can enable the feature by using the following code:

    BOOL sonarStatus = TRUE;
    SystemParametersInfo(SPI_SETMOUSESONAR, 0, &sonarStatus, 0);

    But when I disable it by change sonarStatus to FALSE, the change doesn't seem to be applied.

    Is there something wrong with my understanding of the SystemParametersInfo function or the SPI_SETMOUSESONAR parameter?

    Thursday, January 9, 2014 6:46 AM

Answers

  • I've hit the same problem with SPI_SETFOREGROUNDLOCKTIMEOUT.  The correct solution there was:

    DWORD timeout = 1000; /* or whatever value */
    SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, (void *) timeout, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE);

    I originally attempted to use &timeout as pvParam, but that just did not work.

    • Marked as answer by tsukishiro Friday, January 10, 2014 12:58 AM
    Thursday, January 9, 2014 7:53 PM

All replies

  • I can enable the feature by using the following code:

    BOOL sonarStatus = TRUE;
    SystemParametersInfo(SPI_SETMOUSESONAR, 0, &sonarStatus, 0);

    But when I disable it by change sonarStatus to FALSE, the change doesn't seem to be applied.
    Is there something wrong with my understanding of the SystemParametersInfo function or the SPI_SETMOUSESONAR parameter?

    Try passing just TRUE or FALSE rather than a pointer to a TRUE/FALSE
    value.

    Dave

    Thursday, January 9, 2014 8:22 AM
  • I've hit the same problem with SPI_SETFOREGROUNDLOCKTIMEOUT.  The correct solution there was:

    DWORD timeout = 1000; /* or whatever value */
    SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, (void *) timeout, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE);

    I originally attempted to use &timeout as pvParam, but that just did not work.

    • Marked as answer by tsukishiro Friday, January 10, 2014 12:58 AM
    Thursday, January 9, 2014 7:53 PM
  • Hi Dave,

    Thanks for the advice but I have already tried that before I posted this question.

    If I use TRUE or FALSE, I get a compile error like 'BOOL SystemParametersInfoW(UINT,UINT,PVOID,UINT)' : cannot convert argument 3 from 'bool' to 'PVOID'

    Friday, January 10, 2014 12:55 AM
  • Hi Ranta,

    Thanks for sharing your experience.

    I am now using the following code to enable Mouse Sonar:

    SystemParametersInfo(SPI_SETMOUSESONAR, 0, (void *)TRUE, 0);

    and to disable it, I just replace TRUE with FALSE and it works!

    Friday, January 10, 2014 1:00 AM
  • Thanks for the advice but I have already tried that before I posted this question.
    If I use TRUE or FALSE, I get a compile error like 'BOOL SystemParametersInfoW(UINT,UINT,PVOID,UINT)' : cannot convert argument 3 from 'bool' to 'PVOID'

    I see from your other post that you've sussed that you needed to
    provide a cast.

    Dave

    Friday, January 10, 2014 8:16 AM