Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

SystemParametersInfo() - Screensaver

Posted on 1999-07-24
2
Medium Priority
?
1,277 Views
Last Modified: 2008-03-17
I'd like to enable/disable and set the delay time for
the screensaver from a VB app. I'm using the following:


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

Private Const SPI_SETSCREENSAVEACTIVE = 17
Private Const SPI_SETSCREENSAVETIMEOUT = 15
Private Const SPI_GETSCREENSAVEACTIVE = 16
Private Const SPI_GETSCREENSAVETIMEOUT = 14
Private Const SPIF_SENDWININICHANGE = &H2
Private Const SPIF_UPDATEINIFILE = &H1


and calling SystemParametersInfo() like this:


SystemParametersInfo SPI_SETSCREENSAVEACTIVE, True, _
      0, SPIF_SENDWININICHANGE Or SPIF_UPDATEINIFILE
SystemParametersInfo SPI_SETSCREENSAVEACTIVE, False, _
      0, SPIF_SENDWININICHANGE Or SPIF_UPDATEINIFILE

to enable/disable, and like this:

SystemParametersInfo SPI_SETSCREENSAVETIMEOUT, _
      NewTime, 0, SPIF_SENDWININICHANGE Or _
      SPIF_UPDATEINIFILE

where NewTime is a long containing the desired delay
in seconds, for setting the delay. Each call always
returns 0 and has no effect. Calling GetLastError()
immediately after each call always returns 0.

I'm using VB6 in Win98.

What am I missing?
0
Comment
Question by:coredog
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 6

Accepted Solution

by:
VBGuru earned 150 total points
ID: 1527277
Instaed use it like this

Option Explicit
Private Declare Function SystemParametersInfo Lib _
"user32" Alias "SystemParametersInfoA" _
(ByVal uAction As Long, ByVal uParam _
As Long, ByRef lpvParam As Any, ByVal _
fuWinIni As Long) As Long

Private Const SPI_SETSCREENSAVETIMEOUT = 15
Private Const SPI_GETSCREENSAVETIMEOUT = 14

Private Sub Form_Click()
Dim Newtime As Long

Newtime = 240
Call SystemParametersInfo(SPI_SETSCREENSAVETIMEOUT, Newtime, ByVal 0&, 0)
Newtime = 0
Call SystemParametersInfo(SPI_GETSCREENSAVETIMEOUT, ByVal 0&, Newtime, 0)
MsgBox Newtime
End Sub
0
 

Author Comment

by:coredog
ID: 1527278
It works, thanks.
0

Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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 utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

670 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