Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to shut the screensaver

Posted on 1999-01-21
1
Medium Priority
?
265 Views
Last Modified: 2011-09-20
I would like to shut the screen saver from a vbCode does anybody know how to do it?
0
Comment
Question by:Brickner
1 Comment
 
LVL 1

Accepted Solution

by:
rondeauj earned 200 total points
ID: 1469882
VB Declaration

Declare Function SystemParametersInfo& Lib "user32" Alias _
"SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, lpvParam _
As Any, ByVal fuWinIni As Long)
Declare Function SystemParametersInfoByVal& Lib "user32" Alias _
"SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, ByVal _
lpvParam As Any, ByVal fuWinIni As Long)

Description

Allows the retrieval and setting of a number of Windows system parameters.

Use with VB

This is one of the few cases where a single function takes so many different parameters that it might make sense to use the As Any parameter type. Use extreme caution to be sure that the lpvParam parameter is of the correct data type before calling this function. It is strongly recommended that you create type safe aliases for your own application for those parameter types that you need.

Parameter      Type/Description
uAction      Long—Specifies the parameter to set. Refer to the constants in the table that follows.
uParam      Long—Refer to uAction table below.
lpvParam      Any—Integer, Long, and data structures are called by reference. Use SystemParametersInfoByval with String data. Refer to uAction table below for use.
fuWinIni      Long—Depending on parameter and operating system, user configuration parameters set with this function are stored in the file win.ini, the registration database, or both. This parameter specifies whether the user settings should be updated when setting system parameters. May be zero (to prevent the update) or one of the following constants:SPIF_UPDATEINIFILE: Updates the user profile in win.ini and/or the registration database.SPIF_SENDWININICHANGE: Causes a WM_WININICHANGE message to be sent to all applications when SPIF_UPDATEINIFILE is also set. Otherwise has no effect. This message informs applications that the user configuration settings have been changed.
uAction Table

Refer to your Windows manual for information on these parameters and the registration database or WIN.INI file. Parameters that are not specified for an action are not used. In many cases a system parameter has corresponding GET and SET actions, for example, SPI_GETACCESSTIMEOUT and SPI_SETACCESSTIMEOUT. In these cases, unless otherwise specified, the only difference between them is that one retrieves the information and the other sets it. Only parameter differences will be listed for the SET action entry.

SPI_GETACCESSTIMEOUT      lpvParam is an ACCESSTIMEOUT structure that will be loaded with accessability features timing information. uParam must be set to the size of the ACCESSTIMEOUT structure before calling the function.
SPI_GETANIMATION      lpvParam is an ANIMATIONINFO structure that will be loaded with minimize and restore animation information.  No NT 3.51
SPI_GETBEEP      lpvParam is a long that will be set TRUE if the beep sound is on.
SPI_GETBORDER      lpvParam is a long that receives a multiplier that controls the sizeable window border size.
SPI_GETDEFAULTINPUTLANG      lpvParam is a long that receives a 32-bit handle to the default keyboard layout. No NT 3.51.
SPI_GETDRAGFULLWINDOWS      lpvParam is a long that will be set TRUE if dragging moves the entire window. FALSE if only a rectangle outline is dragged. Requires NT4.0 or Win95 with Plus! pack.
SPI_GETFASTTASKSWITCH      lpvParam is a long that will be set TRUE if fast task switching is enabled. Always True for Win95 and NT4.0
SPI_GETFILTERKEYS      lpvParam is an FILTERKEYS structure that will be loaded with keyboard related accessability feature information.
SPI_GETFONTSMOOTHING      lpvParam is a long that will be set True if anit-aliasing is turned on to make fonts look smoother. NT4.0 and Win95 with Plus! pack only.
SPI_GETGRIDGRANULARITY      lpvParam is a long that will be set to the grid granularity value.
SPI_GETHIGHCONTRAST      lpvParam is a HIGHCONTRAST structure that will be loaded with user display related accessability feature information. Win95 only.
SPI_GETICONMETRICS      lpvParam is an ICONMETRICS structure that will be loaded with information relating to the scaling and arrangement of icons. Win95 & NT 4.0.
SPI_GETICONTITLELOGFONT      lpvParam points to a LOGFONT structure that will be set according to the font used for icon titles.
SPI_GETICONTITLEWRAP      lpvParam is a long that will be set TRUE if icon title wrapping is enabled.
SPI_GETKEYBOARDDELAY      lpvParam is a long that will be set to the keyboard repeat delay.
SPI_GETKEYBOARDPREF      lpvParam is a long that will be set TRUE if the user prefers to use the keyboard over the mouse. When this parameter is true, Windows displays additional keyboard interface information. Win95 only.
SPI_GETKEYBOARDSPEED      lpvParam is a long that will be set to the keyboard repeat speed.
SPI_GETMENUDROPALIGNMENT      lpvParam is a long that will be set FALSE if popup menus are left aligned (default), TRUE for right aligned.
SPI_GETMINIMIZEDMETRICS      lpvParam is a MINIMIZEDMETRICS structure that will be loaded with information relating to the scaling and arrangement of minimized windows. Win95 only.
SPI_GETMOUSE      lpvParam is the first entry in a three-element long array. Entry 0 is set to the user configuration MouseThreshold1 field, entry 1 to MouseThreshold2, and entry 2 to MouseSpeed.
SPI_GETMOUSEKEYS      lpvParam is a MOUSEKEYS structure that will be loaded with mouse related accessability feature information. No NT 3.51
SPI_GETNONCLIENTMETRICS      lpvParam is a NONCLIENTMETRICS structure that will be loaded with information about the fonts and metrics involved in drawing the non-client area of a window (borders, captions, etc.). Win95 only.
SPI_GETSCREENSAVEACTIVE      lpvParam points to an integer that will be set TRUE if the screen saver is active, FALSE otherwise.
SPI_GETSCREENSAVETIMEOUT      lpvParam points to an integer that will be set to the screen save time-out in seconds.
SPI_GETSERIALKEYS      lpvParam is a SERIALKEYS structure that will be loaded with accessability feature information related to input devices that simulate keyboard input. Win95 only.
SPI_GETSHOWSOUNDS      lpvParam is a long that will be set TRUE if applications should use visual cues in place of sound. This is the same as the SM_GETSHOWSOUNDS option of the GetSystemMetrics function.
SPI_GETSNAPTODEFBUTTON      lpvParam is a long that will be set TRUE if the mouse will automatically move to the default button on a new dialog. NT 4.0 only.
SPI_GETSOUNDSENTRY      lpvParam is a SOUNDSENTRY structure that will be loaded with accessability feature information related to having Windows provide visual indications in place of system sounds. uParam must be set to the size of the SOUNDSENTRY structure before the call.
SPI_GETSTICKYKEYS      lpvParam is a STICKYKEYS structure that will be loaded with accessability feature information related to allowing a user to press keys in sequence instead of simultaneously (for example: shift+, control+, alt+). uParam must be set to the size of the STICKYKEYS structure before the call.
SPI_GETTOGGLEKEYS      lpvParam is a TOGGLEKEYS structure that will be loaded with accessability feature information relating to the tone generated when pressing a toggle key (num-lock, caps-lock, scroll-lock). Windows will use a different tone to indicate the on and off states. . uParam must be set to the size of the TOGGLEKEYS structure before the call.
SPI_GETWORKAREA      lpvParam is a RECT structure that is loaded with the working area of the screen.
SPI_ICONHORIZONTALSPACING      If lpvParam is NULL, uParam is the new width for icon spacing on the desktop in pixels.
SPI_ICONVERTICALSPACING      Same as SPI_ICONHORIZONTALSPACING for the vertical icon spacing.
SPI_LANGDRIVER      lpvParam is a string with the new language driver file name.
SPI_SETACCESSTIMEOUT      Same parameters as SPI_GETACCESSTIMEOUT.
SPI_SETANIMATION      Same parameters as SPI_GETANIMATION.
SPI_SETBEEP      uParam is TRUE to turn the beep sound on, FALSE to turn it off.
SPI_SETBORDER      uParam is the multiplier that controls the sizeable window border size.
SPI_SETDEFAULTINPUTLANG      Same parameters as SPI_GETDEFAULTINPUTLANG.
SPI_SETDESKPATTERN      Forces windows to restore the current desktop pattern from the registration database or win.ini.
SPI_SETDESKWALLPAPER      lpvParam is a string containing the name of a bitmap file to use as the desktop wallpaper.
SPI_SETDOUBLECLICKTIME      uParam is the number of milliseconds between two clicks within which they will be considered a single double click.
SPI_SETDOUBLECLKHEIGHT      uParam is the new double click height. See the comments for the GetSystemMetrics function for details.
SPI_SETDOUBLECLKWIDTH      uParam is the new double click width. See the comments for the GetSystemMetrics function for details.
SPI_DRAGFULLWINDOWS      uParam is TRUE to turn on full window dragging, FALSE otherwise. Win95 only.
SPI_SETDRAGHEIGHT      uParam is the height in pixels of the rectangle that determines if a drag operation is starting. Win95 only.
SPI_SETDRAGWIDTH      uParam is the width in pixels of the rectangle that determines if a drag operation is starting. Win95 only.
SPI_SETFASTTASKSWITCH      uParam is TRUE to turn on fast task switching, FALSE to turn it off.
SPI_FILTERKEYS      Same parameters as SPI_GETFILTERKEYS.
SPI_SETFONTSMOOTHING      uParam is a TRUE to turn on font smoothing. NT4.0 and Win95 with Plus! pack only.
SPI_SETGRIDGRANULARITY      uParam is the new grid granularity.
SPI_SETHIGHCONTRAST      Same parameters as SPI_GETHIGHCONTRAST.
SPI_SETICONMETRICS      Same parameters as SPI_GETICONMETRICS.
SPI_SETICONTITLELOGFONT      lpvParam is a LOGFONT structure that will define the font to use for icon titles. uParam is the size of the LOGFONT structure. If both are NULL, the font defined during system startup will be used.
SPI_SETICONTITLEWRAP      uParam is TRUE to turn on icon title wrapping.
SPI_SETKEYBOARDDELAY      uParam is the new keyboard repeat delay.
SPI_SETKEYBOARDPREF      uParam is TRUE to indicate that the user prefers to use the keyboard over the mouse. See SPI_GETKEYBOARDPREF.
SPI_SETKEYBOARDSPEED      uParam is the new keyboard repeat speed.
SPI_SETLANGTOGGLE      Causes windows to reload the hotkey information for switching between keyboard layouts from the system registry.
SPI_SETLOWPOWERACTIVE      uParam is TRUE to enable the low power screen saver mode. Win95 only.
SPI_SETLOWPOWERTIMEOUT      uParam is the new low power screen saver timeout. Win95 only.
SPI_SETMENUDROPALIGNMENT      uParam is FALSE to set left aligned popup menus, TRUE for right aligned.
SPI_SETMINIMIZEDMETRICS      Same parameters as SPI_GETMINIMIZEDMETRICS.
SPI_SETMOUSE      lpvParam is the first entry in a three-element integer array containing mouse settings. See SPI_GETMOUSE for details.
SPI_SETMOUSEBUTTONSWAP      uParam is TRUE to swap the meaning of the left and right mouse buttons, FALSE to use original values.
SPI_SETMOUSEKEYS      Same parameters as SPI_GETMOUSEKEYS.
SPI_SETNONCLIENTMETRICS      Same parameters as SPI_GETNONCLIENTMETRICS.
SPI_SETPENWINDOWS      uParam is TRUE to load pen windows, FALSE to unload.
SPI_SETPOWEROFFACTIVE      uParam is TRUE to enable the power down screen saver mode. Win95 only.
SPI_SETPOWEROFFTIMEOUT      uParam is the new power down screen saver timeout. Win95 only.
SPI_SETSCREENREADER      uParam is TRUE if a screen reader utility is running. See SPI_GETSCREENREADER.
SPI_SETSCREENSAVEACTIVE      uParam is TRUE to activate the screen saver, FALSE to deactivate.
SPI_SETSCREENSAVETIMEOUT      uParam is the new screen save time-out in seconds.
SPI_SETSERIALKEYS      Same parameters as SPI_GETSERIALKEYS.
SPI_SETSHOWSOUNDS      uParam is TRUE to enable the windows showsounds accessability features. See SPI_GETSHOWSOUNDS.
SPI_SETSNAPTODEFBUTTON      uParam is a TRUE if the mouse should automatically move to the default button on a new dialog. NT 4.0 only.
SPI_SETSOUNDSENTRY      Same as SPI_GETSOUNDSENTRY.
SPI_SETSTICKYKEYS      Same as SPI_GETSTICKYKEYS.
SPI_SETTOGGLEKEYS      Same as SPI_GETTOGGLEKEYS.
SPI_SETWORKAREA      Same as SPI_GETWORKAREA.
Return Value

Long—Nonzero on success, zero on failure. Sets GetLastError.

Platform

Windows 95, Windows NT, Win16 (see individual parameters).
Refer to the latest Win32 documentation for the latest new constants supported by this function. Microsoft may add contants with each version of NT and Windows 95 including service pack and extension pack updates. This table has been updated as of NT 4.0, but does not include constants referring to the new mouse wheel support for NT 4.0.

Porting Notes

Be careful: In many cases where lpvParam pointed to an integer variable under Win16 (for example, with booleans), it now points to a long.

0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

879 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question