DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 5 of 5
  1. #1
    Ben Neville Guest

    Screensaver timeout value query

    If I change the Timeout value in the registry for my ScreenSaver using VB
    the system only seem to become aware of the new value the next time I log
    on.

    If I change this in Control Panel it appears to take affect immediately.

    I know for environment variable changes I can use something along the lines
    of
    SendMessageTimeout HWND_BROADCAST, WM_SETTINGCHANGE, & _
    0, "Environment", SMTO_ABORTIFHUNG, 5000, dwReturnValue

    This however does not appear to refresh the screensaver settings which are
    stored in. "HKEY_CURRENT_USER\Control Panel\Desktop\NoDispScrSavPage"

    Does anyone know how to alert the system of this change.

    Rgds
    Ben






  2. #2
    Tom Esh Guest

    Re: Screensaver timeout value query

    You can do it all with one call to the SystemParametersInfo Api
    function instead. It handles reading/writing to the registry and
    applies the changes immediately.

    Public Const SPI_GETSCREENSAVETIMEOUT = 14
    Public Const SPI_SETSCREENSAVETIMEOUT = 15
    Public Const SPIF_UPDATEINIFILE = &H1
    Public Const SPIF_SENDWININICHANGE = &H2
    Public Declare Function SystemParametersInfo Lib "user32" _
    Alias "SystemParametersInfoA" _
    (ByVal uAction As Long, ByVal uParam As Long, _
    lpvParam As Any, ByVal fuWinIni As Long) As Long

    'change timeout to 3 mins...
    SystemParametersInfo SPI_SETSCREENSAVETIMEOUT, 180&, _
    ByVal 0&, SPIF_UPDATEINIFILE Or SPIF_SENDWININICHANGE

    'retreive current setting...
    Dim lSecs As Long
    SystemParametersInfo SPI_GETSCREENSAVETIMEOUT, 0&, lSecs, 0&
    Debug.Print "current SS timeout=" & lSecs \ 60 & " min"

    On Tue, 20 Mar 2001 23:49:18 -0500, "Ben Neville"
    <bneville@programmer.net> wrote:

    >If I change the Timeout value in the registry for my ScreenSaver using VB
    >the system only seem to become aware of the new value the next time I log
    >on.
    >
    >If I change this in Control Panel it appears to take affect immediately.
    >
    >I know for environment variable changes I can use something along the lines
    >of
    >SendMessageTimeout HWND_BROADCAST, WM_SETTINGCHANGE, & _
    >0, "Environment", SMTO_ABORTIFHUNG, 5000, dwReturnValue
    >
    >This however does not appear to refresh the screensaver settings which are
    >stored in. "HKEY_CURRENT_USER\Control Panel\Desktop\NoDispScrSavPage"
    >
    >Does anyone know how to alert the system of this change.
    >
    >Rgds
    >Ben
    >
    >
    >
    >
    >



    -Tom
    (please post replies to the newsgroup)

  3. #3
    Tom Esh Guest

    Re: Screensaver timeout value query

    You can do it all with one call to the SystemParametersInfo Api
    function instead. It handles reading/writing to the registry and
    applies the changes immediately.

    Public Const SPI_GETSCREENSAVETIMEOUT = 14
    Public Const SPI_SETSCREENSAVETIMEOUT = 15
    Public Const SPIF_UPDATEINIFILE = &H1
    Public Const SPIF_SENDWININICHANGE = &H2
    Public Declare Function SystemParametersInfo Lib "user32" _
    Alias "SystemParametersInfoA" _
    (ByVal uAction As Long, ByVal uParam As Long, _
    lpvParam As Any, ByVal fuWinIni As Long) As Long

    'change timeout to 3 mins...
    SystemParametersInfo SPI_SETSCREENSAVETIMEOUT, 180&, _
    ByVal 0&, SPIF_UPDATEINIFILE Or SPIF_SENDWININICHANGE

    'retreive current setting...
    Dim lSecs As Long
    SystemParametersInfo SPI_GETSCREENSAVETIMEOUT, 0&, lSecs, 0&
    Debug.Print "current SS timeout=" & lSecs \ 60 & " min"

    On Tue, 20 Mar 2001 23:49:18 -0500, "Ben Neville"
    <bneville@programmer.net> wrote:

    >If I change the Timeout value in the registry for my ScreenSaver using VB
    >the system only seem to become aware of the new value the next time I log
    >on.
    >
    >If I change this in Control Panel it appears to take affect immediately.
    >
    >I know for environment variable changes I can use something along the lines
    >of
    >SendMessageTimeout HWND_BROADCAST, WM_SETTINGCHANGE, & _
    >0, "Environment", SMTO_ABORTIFHUNG, 5000, dwReturnValue
    >
    >This however does not appear to refresh the screensaver settings which are
    >stored in. "HKEY_CURRENT_USER\Control Panel\Desktop\NoDispScrSavPage"
    >
    >Does anyone know how to alert the system of this change.
    >
    >Rgds
    >Ben
    >
    >
    >
    >
    >



    -Tom
    (please post replies to the newsgroup)

  4. #4
    Ben Neville Guest

    Re: Screensaver timeout value query

    Thanks Tom that worked well.

    "Tom Esh" <tjeshGibberish@blazenet.net> wrote in message
    news:3ab86191.14094085@news.devx.com...
    > You can do it all with one call to the SystemParametersInfo Api
    > function instead. It handles reading/writing to the registry and
    > applies the changes immediately.
    >
    > Public Const SPI_GETSCREENSAVETIMEOUT = 14
    > Public Const SPI_SETSCREENSAVETIMEOUT = 15
    > Public Const SPIF_UPDATEINIFILE = &H1
    > Public Const SPIF_SENDWININICHANGE = &H2
    > Public Declare Function SystemParametersInfo Lib "user32" _
    > Alias "SystemParametersInfoA" _
    > (ByVal uAction As Long, ByVal uParam As Long, _
    > lpvParam As Any, ByVal fuWinIni As Long) As Long
    >
    > 'change timeout to 3 mins...
    > SystemParametersInfo SPI_SETSCREENSAVETIMEOUT, 180&, _
    > ByVal 0&, SPIF_UPDATEINIFILE Or SPIF_SENDWININICHANGE
    >
    > 'retreive current setting...
    > Dim lSecs As Long
    > SystemParametersInfo SPI_GETSCREENSAVETIMEOUT, 0&, lSecs, 0&
    > Debug.Print "current SS timeout=" & lSecs \ 60 & " min"
    >
    > On Tue, 20 Mar 2001 23:49:18 -0500, "Ben Neville"
    > <bneville@programmer.net> wrote:
    >
    > >If I change the Timeout value in the registry for my ScreenSaver using VB
    > >the system only seem to become aware of the new value the next time I log
    > >on.
    > >
    > >If I change this in Control Panel it appears to take affect immediately.
    > >
    > >I know for environment variable changes I can use something along the

    lines
    > >of
    > >SendMessageTimeout HWND_BROADCAST, WM_SETTINGCHANGE, & _
    > >0, "Environment", SMTO_ABORTIFHUNG, 5000, dwReturnValue
    > >
    > >This however does not appear to refresh the screensaver settings which

    are
    > >stored in. "HKEY_CURRENT_USER\Control Panel\Desktop\NoDispScrSavPage"
    > >
    > >Does anyone know how to alert the system of this change.
    > >
    > >Rgds
    > >Ben
    > >
    > >
    > >
    > >
    > >

    >
    >
    > -Tom
    > (please post replies to the newsgroup)




  5. #5
    Ben Neville Guest

    Re: Screensaver timeout value query

    Thanks Tom that worked well.

    "Tom Esh" <tjeshGibberish@blazenet.net> wrote in message
    news:3ab86191.14094085@news.devx.com...
    > You can do it all with one call to the SystemParametersInfo Api
    > function instead. It handles reading/writing to the registry and
    > applies the changes immediately.
    >
    > Public Const SPI_GETSCREENSAVETIMEOUT = 14
    > Public Const SPI_SETSCREENSAVETIMEOUT = 15
    > Public Const SPIF_UPDATEINIFILE = &H1
    > Public Const SPIF_SENDWININICHANGE = &H2
    > Public Declare Function SystemParametersInfo Lib "user32" _
    > Alias "SystemParametersInfoA" _
    > (ByVal uAction As Long, ByVal uParam As Long, _
    > lpvParam As Any, ByVal fuWinIni As Long) As Long
    >
    > 'change timeout to 3 mins...
    > SystemParametersInfo SPI_SETSCREENSAVETIMEOUT, 180&, _
    > ByVal 0&, SPIF_UPDATEINIFILE Or SPIF_SENDWININICHANGE
    >
    > 'retreive current setting...
    > Dim lSecs As Long
    > SystemParametersInfo SPI_GETSCREENSAVETIMEOUT, 0&, lSecs, 0&
    > Debug.Print "current SS timeout=" & lSecs \ 60 & " min"
    >
    > On Tue, 20 Mar 2001 23:49:18 -0500, "Ben Neville"
    > <bneville@programmer.net> wrote:
    >
    > >If I change the Timeout value in the registry for my ScreenSaver using VB
    > >the system only seem to become aware of the new value the next time I log
    > >on.
    > >
    > >If I change this in Control Panel it appears to take affect immediately.
    > >
    > >I know for environment variable changes I can use something along the

    lines
    > >of
    > >SendMessageTimeout HWND_BROADCAST, WM_SETTINGCHANGE, & _
    > >0, "Environment", SMTO_ABORTIFHUNG, 5000, dwReturnValue
    > >
    > >This however does not appear to refresh the screensaver settings which

    are
    > >stored in. "HKEY_CURRENT_USER\Control Panel\Desktop\NoDispScrSavPage"
    > >
    > >Does anyone know how to alert the system of this change.
    > >
    > >Rgds
    > >Ben
    > >
    > >
    > >
    > >
    > >

    >
    >
    > -Tom
    > (please post replies to the newsgroup)




Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links