SystemParametersInfo

3.1

  BOOL SystemParametersInfo(uAction, uParam, lpvParam, fuWinIni)    
  UINT uAction; /* system parameter to query or set */
  UINT uParam; /* depends on system parameter */
  void FAR* lpvParam; /* depends on system parameter */
  UINT fuWinIni; /* WIN.INI update flag */

The SystemParametersInfo function queries or sets system-wide parameters. This function can also update the WIN.INI file while setting a parameter.

Parameters

uAction

Specifies the system-wide parameter to query or set. This parameter can be one of the following values:

Value Meaning

SPI_GETBEEP Retrieves a BOOL value that indicates whether the warning beep is on or off.
SPI_GETBORDER Retrieves the border multiplying factor that determines the width of a window's sizing border.
SPI_GETFASTTASKSWITCH Determines whether fast task switching is on or off.
SPI_GETGRIDGRANULARITY Retrieves the current granularity value of the desktop sizing grid.
SPI_GETICONTITLELOGFONT Retrieves the logical-font information for the current icon-title font.
SPI_GETICONTITLEWRAP Determines whether icon-title wrapping is on or off.
SPI_GETKEYBOARDDELAY Retrieves the keyboard repeat-delay setting.
SPI_GETKEYBOARDSPEED Retrieves the keyboard repeat-speed setting.
SPI_GETMENUDROPALIGNMENT Determines whether pop-up menus are left-aligned or right-aligned relative to the corresponding menu-bar item.
SPI_GETMOUSE Retrieves the mouse speed and the mouse threshold values, which Windows uses to calculate mouse acceleration.
SPI_GETSCREENSAVEACTIVE Retrieves a BOOL value that indicates whether screen saving is on or off.
SPI_GETSCREENSAVETIMEOUT Retrieves the screen-saver time-out value.
SPI_ICONHORIZONTALSPACING Sets the width, in pixels, of an icon cell.
SPI_ICONVERTICALSPACING Sets the height, in pixels, of an icon cell.
SPI_LANGDRIVER Forces the user to load a new language driver.
SPI_SETBEEP Turns the warning beep on or off.
SPI_SETBORDER Sets the border multiplying factor that determines the width of a window's sizing border.
SPI_SETDESKPATTERN Sets the current desktop pattern to the value specified in the Pattern entry in the WIN.INI file or to the pattern specified by the lpvParam parameter.
SPI_SETDESKWALLPAPER Specifies the filename that contains the bitmap to be used as the desktop wallpaper.
SPI_SETDOUBLECLKHEIGHT Sets the height of the rectangle within which the second click of a double-click must fall for it to be registered as a double-click.
SPI_SETDOUBLECLICKTIME Sets the double-click time for the mouse. The double-click time is the maximum number of milliseconds that may occur between the first and second clicks of a double-click.
SPI_SETDOUBLECLKWIDTH Sets the width of the rectangle in which the second click of a double-click must fall to be registered as a double-click.
SPI_SETFASTTASKSWITCH Turns fast task switching on or off.
SPI_SETGRIDGRANULARITY Sets the granularity of the desktop sizing grid.
SPI_SETICONTITLELOGFONT Sets the font that is used for icon titles.
SPI_SETICONTITLEWRAP Turns icon-title wrapping on or off.
SPI_SETKEYBOARDDELAY Sets the keyboard repeat-delay setting.
SPI_SETKEYBOARDSPEED Sets the keyboard repeat-speed setting.
SPI_SETMENUDROPALIGNMENT Sets the alignment value of pop-up menus.
SPI_SETMOUSE Sets the mouse speed and the x and y mouse-threshold values.
SPI_SETMOUSEBUTTONSWAP Swaps or restores the meaning of the left and right mouse buttons.
SPI_SETSCREENSAVEACTIVE Sets the state of the screen saver.
SPI_SETSCREENSAVETIMEOUT Sets the screen-saver time-out value.

uParam

Depends on the uAction parameter. For more information, see the following Comments section.

lpvParam

Depends on the uAction parameter. For more information, see the following Comments section.

fuWinIni

If a system parameter is being set, specifies whether the WIN.INI file is updated, and if so, whether the WM_WININICHANGE message is broadcast to all top-level windows to notify them of the change. This parameter can be a combination of the following values:

Value Meaning

SPIF_UPDATEINIFILE Writes the new system-wide parameter setting to the WIN.INI file.
SPIF_SENDWININICHANGE Broadcasts a WM_WININICHANGE message after WIN.INI is updated. This flag has no effect if SPIF_UPDATEINIFILE is not specified.

Return Value

The return value is nonzero if the function is successful. Otherwise, it is zero.

Comments

The SystemParameterInfo function is intended for applications, such as Control Panel, that allow the user to customize the Windows environment.

The following table describes the uParam and lpvParam parameters for each SPI_ constant:

Constant uParam lpvParam

SPI_GETBEEP 0 Points to a BOOL variable that receives TRUE if the beep is on, FALSE if it is off.
SPI_GETBORDER 0 Points to an integer variable that receives the border multiplying factor.
SPI_GETFASTTASKSWITCH 0 Points to a BOOL variable that receives TRUE if fast task switching is on, FALSE if it is off.
SPI_GETGRIDGRANULARITY 0 Points to an integer variable that receives the grid-granularity value.
SPI_GETICONTITLELOGFONT Size of LOGFONT structure Points to a LOGFONT structure that receives the logical-font information.
SPI_GETICONTITLEWRAP 0 Points to a BOOL variable that receives TRUE if wrapping is on, FALSE if wrapping is off.
SPI_GETKEYBOARDDELAY 0 Points to an integer variable that receives the keyboard repeat-delay setting.
SPI_GETKEYBOARDSPEED 0 Points to a WORD variable that receives the current keyboard repeat-speed setting.
SPI_GETMENUDROPALIGNMENT 0 Points to a BOOL variable that receives TRUE if pop-up menus are right-aligned, FALSE if they are left-aligned.
SPI_GETMOUSE 0 Points to an integer array name lpiMouse, where lpiMouse[0] receives the WIN.INI entry MouseThreshold1, lpiMouse[1] receives the entry MouseThreshold2, and lpiMouse[2] receives the entry MouseSpeed.
SPI_GETSCREENSAVEACTIVE 0 Points to a BOOL variable that receives TRUE if the screen saver is active, FALSE if it is not.
SPI_GETSCREENSAVETIMEOUT 0 Points to an integer variable that receives the screen-saver time-out value, in milliseconds.
SPI_ICONHORIZONTALSPACING New width, in pixels, for horizontal spacing of icons Is NULL if the icon cell width, in pixels, is returned in uParam. If this value is a pointer to an integer, the current horizontal spacing is returned in that variable and uParam is ignored.
SPI_ICONVERTICALSPACING New height, in pixels, for vertical spacing of icons Is NULL if the icon cell height, in pixels, is returned in uParam. If this value is a pointer to an integer, the current vertical spacing is returned in that variable and uParam is ignored.
SPI_LANGDRIVER 0 Points to a string containing the new language driver filename. The application should make sure that all other international settings remain consistent when changing the language driver.
SPI_SETBEEP TRUE = turn the beep on; FALSE = turn the beep off Is NULL.
SPI_SETBORDER Border multiplying factor Is NULL.
SPI_SETDESKPATTERN 0 or –1 Specifies the desktop pattern. If this value is NULL and the uParam parameter is –1, the value is reread from the WIN.INI file. This value can also be a null-terminated string (LPSTR) containing a sequence of 8 numbers that represent the new desktop pattern; for example, “170 85 170 85 170 85 170 85” represents a 50% gray pattern.
SPI_SETDESKWALLPAPER 0 Points to a string that specifies the name of the bitmap file.
SPI_SETDOUBLECLKHEIGHT Double-click height, in pixels Is NULL.
SPI_SETDOUBLECLICKTIME Double-click time, in milliseconds Is NULL.
SPI_SETDOUBLECLKWIDTH Double-click width, in pixels Is NULL.
SPI_SETFASTTASKSWITCH TRUE = turn on fast task switching; FALSE = turn it off Is NULL.
SPI_SETGRIDGRANULARITY Grid granularity, ,  
SPI_SETICONTITLELOGFONT Size of the LOGFONT structure Points to a LOGFONT structure that defines the font to use for icon titles. If uParam is set to zero and lParam is set to NULL, Windows uses the icon-title font and spacings that were in effect when Windows was started.
SPI_SETICONTITLEWRAP TRUE = turn wrapping on; FALSE = turn wrapping off Is NULL.
SPI_SETKEYBOARDDELAY Keyboard-delay setting Is NULL.
SPI_SETKEYBOARDSPEED Repeat-speed setting Is NULL.
SPI_SETMENUDROPALIGNMENT TRUE = right-alignment; FALSE = left-alignment Is NULL.
SPI_SETMOUSE 0 Points to an integer array named lpiMouse, where lpiMouse[0] receives the WIN.INI entry xMouseThreshold, lpiMouse[1] receives the entry yMouseThreshold, and lpiMouse[2] receives the entry MouseSpeed.
SPI_SETMOUSEBUTTONSWAP TRUE = reverse the meaning of the left and right mouse buttons; FALSE = restore the buttons to their original meanings Is NULL.
SPI_SETSCREENSAVEACTIVE TRUE = activate screen saving; FALSE = deactivate screen saving Is NULL.
SPI_SETSCREENSAVETIMEOUT Idle time-out duration, in seconds, before screen is saved Is NULL.

Example

The following example retrieves the value for the DoubleClickSpeed entry from the WIN.INI file and uses the value to initialize an edit control. In this example, while the WM_COMMAND message is being processed, the user-specified value is retrieved from the edit control and used to set the double-click time.

char szBuf[32];
int iResult;

case WM_INITDIALOG:

    /* Initialize edit control to the current double-click time. */

    iResult = GetProfileInt("windows",
        "DoubleClickSpeed", 550);
    itoa(iResult, szBuf, 10);
    SendDlgItemMessage(hdlg, IDD_DCLKTIME, WM_SETTEXT, 0,
        (DWORD) (LPSTR) szBuf);

    .
    . /* Initialize any other controls. */
    .

    return FALSE;


case WM_COMMAND:
    switch(wParam) {

        case IDOK:

            /* Set double-click time to a user-specified value. */

            SendDlgItemMessage(hdlg, IDD_DCLKTIME, WM_GETTEXT,
                sizeof(szBuf), (DWORD) (LPSTR) szBuf);
            SystemParametersInfo(SPI_SETDOUBLECLICKTIME, atoi(szBuf),
                (LPVOID) NULL, SPIF_UPDATEINIFILE |
                SPIF_SENDWININICHANGE);
            .
            . /* Set any other system-wide parameters. */
            .


            EndDialog(hdlg, TRUE);
            return TRUE;
    }