How to Use SystemParametersInfo API for Control Panel SettingsLast reviewed: June 21, 1995Article ID: Q97142 |
The information in this article applies to:
- Standard and Professional Editions of Microsoft Visual Basic for Windows, versions 2.0 and 3.0
SUMMARYThe SystemParametersInfo API call can be used to get and set Windows settings that are normally set from the Desktop by using the Control Panel.
MORE INFORMATIONYou can call the SystemParametersInfo API to set and get all the settings controlled by the Windows Control Panel. Normally a user would have to choose the Windows Control Panel to view or change system settings such as granularity, wallpaper, or icon title wrap. Instead of forcing the user to set things manually using the Control Panel you can have your program call the SystemParametersInfo API to set them automatically. Use the following Visual Basic for Windows Declare for the API. Enter it all as one, single line:
Declare Function SystemParametersInfo Lib "User" (ByVal uAction As Integer, ByVal uparam As Integer, lpvParam As Any, ByVal fuWinIni As Integer) As IntegerHere are the formal arguments to the function:
uAction system parameter to query or set uParam depends on system parameter lpvParam depends on system parameter fuWinIni WIN.INI update flagThe uAction argument can be one of the following constants:
CONST SPI_GETBEEP=1 CONST SPI_SETBEEP=2 CONST SPI_GETMOUSE=3 CONST SPI_SETMOUSE=4 CONST SPI_GETBORDER=5 CONST SPI_SETBORDER=6 CONST SPI_GETKEYBOARDSPEED=10 CONST SPI_SETKEYBOARDSPEED=11 CONST SPI_LANGDRIVER=12 CONST SPI_ICONHORIZONTALSPACING=13 CONST SPI_GETSCREENSAVETIMEOUT=14 CONST SPI_SETSCREENSAVETIMEOUT=15 CONST SPI_GETSCREENSAVEACTIVE=16 CONST SPI_SETSCREENSAVEACTIVE=17 CONST SPI_GETGRIDGRANULARITY=18 CONST SPI_SETGRIDGRANULARITY=19 CONST SPI_SETDESKWALLPAPER=20 CONST SPI_SETDESKPATTERN=21 CONST SPI_GETKEYBOARDDELAY=22 CONST SPI_SETKEYBOARDDELAY=23 CONST SPI_ICONVERTICALSPACING=24 CONST SPI_GETICONTITLEWRAP=25 CONST SPI_SETICONTITLEWRAP=26 CONST SPI_GETMENUDROPALIGNMENT=27 CONST SPI_SETMENUDROPALIGNMENT=28 CONST SPI_SETDOUBLECLKWIDTH=29 CONST SPI_SETDOUBLECLKHEIGHT=30 CONST SPI_GETICONTITLELOGFONT=31 CONST SPI_SETDOUBLECLICKTIME=32 CONST SPI_SETMOUSEBUTTONSWAP=33 CONST SPI_SETICONTITLELOGFONT=34 CONST SPI_GETFASTTASKSWITCH=35 CONST SPI_SETFASTTASKSWITCH=36The UParam argument should be 0 when used with a GET constant, and it should contain the new value of the setting when used with a SET constant. The exceptions to these rules are documented in the Windows version 3.1 Software Development Kit (SDK) help file. When used with a GET constant, the lpvParam argument returns the current value of the setting. When used with a SET constant, it is a NULL. The exceptions to these rules are documented in the Windows version 3.1 SDK help file. The fuWinIni argument updates the WIN.INI file:
Const SPIF_SENDWININICHANGE = &H2 Const SPIF_UPDATEINIFILE = &H1 Example OneOne exception to the rules given above occurs with a call to set or get theicon spacing setting. The following example gives the correct argumentsto use to set and get the horizontal spacing:
Example TwoThe example follows the general parameter rules. It demonstrates how to turn icon title wrapping on and off by using SETICONTITLEWRAP.
Example ThreeThis example follows the general parameter rules. It demonstrates how to change your desktop's wallpaper with the SPI_SETDESKWALLPAPER.
|
Additional reference words: 2.00 3.00
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |