How to Use SystemParametersInfo API for Control Panel SettingsID: Q97142
|
The SystemParametersInfo API call can be used to get and set Windows settings that are normally set from the Desktop by using the Control Panel.
You 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 Integer
uAction system parameter to query or set
uParam depends on system parameter
lpvParam depends on system parameter
fuWinIni WIN.INI update flag
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=36
Const SPIF_SENDWININICHANGE = &H2
Const SPIF_UPDATEINIFILE = &H1
Control Name Caption
----------------------
Command1 Read
Command2 Set
Text1
Label1 Icon Horizontal Spacing
Const SPIF_SENDWININICHANGE = &H2
Const SPIF_UPDATEINIFILE = &H1
Const SPI_ICONHORIZONTALSPACING = 13
Dim uAction As Integer
Dim uparam As Integer
' Enter the following Declare 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 Integer
uAction = 0
uparam = 0
ret% = SystemParametersInfo(SPI_ICONHORIZONTALSPACING, uAction,
uparam, SPIF_UPDATEINIFILE Or SPIF_SENDWININICHANGE)
text1.Text = uparam
uAction = Val(text1.Text)
uparam = 0
' Enter the following as one, single line:
x% = SystemParametersInfo(SPI_ICONHORIZONTALSPACING, uAction,
ByVal 0&, SPIF_UPDATEINIFILE Or SPIF_SENDWININICHANGE)
Control Name Caption
-----------------------------
Command1 Wrapping True
Command2 Wrapping False
' Enter the following Declare 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 Integer
Const SPI_SETICONTITLEWRAP = 26
Const SPIF_SENDWININICHANGE = &H2
Const SPIF_UPDATEINIFILE = &H1
' Enter the following as one, single line:
x% = SystemParametersInfo(SPI_SETICONTITLEWRAP, True, 0&,
SPIF_UPDATEINIFILE Or SPIF_SENDWININICHANGE)
' Enter the following as one, single line:
x% = SystemParametersInfo(SPI_SETICONTITLEWRAP, False, 0&,
SPIF_UPDATEINIFILE Or SPIF_SENDWININICHANGE)
Control Name Caption
-----------------------------
Command1 Change Wallpaper to Rivets
Const SPIF_UPDATEINIFILE = &H1
Const SPI_SETDESKWALLPAPER = 20
Const SPIF_SENDWININICHANGE = &H2
' Enter the following Declare as one, single line:
Declare Function SystemParametersInfo Lib "User" (ByVal uAction As
Integer, ByVal uparam As Integer, ByVal lpvParam As String, ByVal
fuWinIni As Integer) As Integer
Sub Command1_Click ()
filenm$ = "C:\Windows\rivets.bmp"
' Enter the following two lines as one, single line:
x% = SystemParametersInfo(SPI_SETDESKWALLPAPER, 0&,
filenm$, SPIF_UPDATEINIFILE Or SPIF_SENDWININICHANGE)
End Sub
Additional query words: 2.00 3.00
Keywords :
Version : WINDOWS:2.0,3.0
Platform : WINDOWS
Issue type :
Last Reviewed: May 21, 1999