I'm using a SystemParametersInfo call to attempt to manage the screen saver.
All I want to do is modify the ScreenSaveActive bit in the registry and have
the OS recognize it (and occasionally set it back to -0-). Theoretically this
should be easy to accomplish through the call shown below. If I trace the
call with SysInternals (si)Registry Monitor I can see the call being made.
Unfortunately in the si QueryValue for the key
HKCU\Software\Policies\Microsoft\Windows\Control
Panel\Desktop\ScreenSaveActive I'm getting a result of BUFOVRFLOW (which I
assume is the trace tool unable to read the value). The value in the registry
does not change.
We do have a forced screen saver GPO applied which I suspect may be causing
the failure. I have checked registry permissions and all is ok on this key.
I've used the SPIF_SENDWININICHANGE parameter with no luck. The following
call is about as basic as I can get for troubleshooting this problem. Any
ideas?
VB.net 1.1, Win2KPro (and XPPro) Also tried C++6.0 and VB6.0.
VB.net call
Private Declare Function SystemParametersInfo Lib "user32" _
Alias "SystemParametersInfoA" (ByVal uAction As Long, ByVal _
uParam As Long, ByVal lpvParam As Long, ByVal fuWinIni As _
Long) As Long
Private Function SetScreenSaver(ByVal Active As Boolean) As Long
Dim lActiveFlag As Long = 0
If Active = True Then lActiveFlag = 1
Return = SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, lActiveFlag, 0, 0)
End Function
-Mike 6 3993
Change all the Longs to Integers. Longs from VB 6.0 convert to Integers in
VB.NET (both are 32-bit integers). That should most likely be the reason for
the failure in VB.NET.
hope that helps..
Imran.
"Mike S." <Mike S.@discussions.microsoft.com> wrote in message
news:41**********************************@microsof t.com... I'm using a SystemParametersInfo call to attempt to manage the screen
saver. All I want to do is modify the ScreenSaveActive bit in the registry and
have the OS recognize it (and occasionally set it back to -0-). Theoretically
this should be easy to accomplish through the call shown below. If I trace the call with SysInternals (si)Registry Monitor I can see the call being made. Unfortunately in the si QueryValue for the key HKCU\Software\Policies\Microsoft\Windows\Control Panel\Desktop\ScreenSaveActive I'm getting a result of BUFOVRFLOW (which I assume is the trace tool unable to read the value). The value in the
registry does not change.
We do have a forced screen saver GPO applied which I suspect may be
causing the failure. I have checked registry permissions and all is ok on this
key. I've used the SPIF_SENDWININICHANGE parameter with no luck. The following call is about as basic as I can get for troubleshooting this problem. Any ideas?
VB.net 1.1, Win2KPro (and XPPro) Also tried C++6.0 and VB6.0.
VB.net call
Private Declare Function SystemParametersInfo Lib "user32" _ Alias "SystemParametersInfoA" (ByVal uAction As Long, ByVal _ uParam As Long, ByVal lpvParam As Long, ByVal fuWinIni As _ Long) As Long
Private Function SetScreenSaver(ByVal Active As Boolean) As Long Dim lActiveFlag As Long = 0 If Active = True Then lActiveFlag = 1 Return = SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, lActiveFlag, 0,
0) End Function
-Mike
Thanks for the quick response Imran!
Actually the code I posted was from one of the tests where I had just
changed those from integers. Unfortunately it didn't make a difference but
I'll post the corrected code below.
Private Declare Function SystemParametersInfo Lib "user32" _
Alias "SystemParametersInfoA" (ByVal uAction As Integer, ByVal _
uParam As Integer, ByVal lpvParam As Integer, ByVal fuWinIni As _
Integer) As Integer
Private Function SetScreenSaver(ByVal Active As Boolean) As Integer
Dim iActiveFlag As Integer = 0
If Active = True Then iActiveFlag = 1
Return SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, iActiveFlag, 0, 0)
End Function
"Imran Koradia" wrote: Change all the Longs to Integers. Longs from VB 6.0 convert to Integers in VB.NET (both are 32-bit integers). That should most likely be the reason for the failure in VB.NET.
hope that helps.. Imran.
"Mike S." <Mike S.@discussions.microsoft.com> wrote in message news:41**********************************@microsof t.com... I'm using a SystemParametersInfo call to attempt to manage the screen saver. All I want to do is modify the ScreenSaveActive bit in the registry and have the OS recognize it (and occasionally set it back to -0-). Theoretically this should be easy to accomplish through the call shown below. If I trace the call with SysInternals (si)Registry Monitor I can see the call being made. Unfortunately in the si QueryValue for the key HKCU\Software\Policies\Microsoft\Windows\Control Panel\Desktop\ScreenSaveActive I'm getting a result of BUFOVRFLOW (which I assume is the trace tool unable to read the value). The value in the registry does not change.
We do have a forced screen saver GPO applied which I suspect may be causing the failure. I have checked registry permissions and all is ok on this key. I've used the SPIF_SENDWININICHANGE parameter with no luck. The following call is about as basic as I can get for troubleshooting this problem. Any ideas?
VB.net 1.1, Win2KPro (and XPPro) Also tried C++6.0 and VB6.0.
VB.net call
Private Declare Function SystemParametersInfo Lib "user32" _ Alias "SystemParametersInfoA" (ByVal uAction As Long, ByVal _ uParam As Long, ByVal lpvParam As Long, ByVal fuWinIni As _ Long) As Long
Private Function SetScreenSaver(ByVal Active As Boolean) As Long Dim lActiveFlag As Long = 0 If Active = True Then lActiveFlag = 1 Return = SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, lActiveFlag, 0, 0) End Function
-Mike
Try using this instead:
Private Const SPI_SETSCREENSAVEACTIVE As Integer = 17
Private Const SPIF_SENDWININICHANGE As Integer = &H2
Private Const SPIF_UPDATEINIFILE As Integer = &H1
Return SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, iActiveFlag, _
0, SPIF_SENDWININICHANGE Or SPIF_UPDATEINIFILE)
hope that helps..
Imran.
"Mike S." <Mike S.@discussions.microsoft.com> wrote in message
news:41**********************************@microsof t.com... I'm using a SystemParametersInfo call to attempt to manage the screen
saver. All I want to do is modify the ScreenSaveActive bit in the registry and
have the OS recognize it (and occasionally set it back to -0-). Theoretically
this should be easy to accomplish through the call shown below. If I trace the call with SysInternals (si)Registry Monitor I can see the call being made. Unfortunately in the si QueryValue for the key HKCU\Software\Policies\Microsoft\Windows\Control Panel\Desktop\ScreenSaveActive I'm getting a result of BUFOVRFLOW (which I assume is the trace tool unable to read the value). The value in the
registry does not change.
We do have a forced screen saver GPO applied which I suspect may be
causing the failure. I have checked registry permissions and all is ok on this
key. I've used the SPIF_SENDWININICHANGE parameter with no luck. The following call is about as basic as I can get for troubleshooting this problem. Any ideas?
VB.net 1.1, Win2KPro (and XPPro) Also tried C++6.0 and VB6.0.
VB.net call
Private Declare Function SystemParametersInfo Lib "user32" _ Alias "SystemParametersInfoA" (ByVal uAction As Long, ByVal _ uParam As Long, ByVal lpvParam As Long, ByVal fuWinIni As _ Long) As Long
Private Function SetScreenSaver(ByVal Active As Boolean) As Long Dim lActiveFlag As Long = 0 If Active = True Then lActiveFlag = 1 Return = SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, lActiveFlag, 0,
0) End Function
-Mike
Still no luck. The call looks like it's going through to user32.dll, but it's
not executing completely or properly. I am getting a return value of 0.
When I look at the registry trace I'm seeing a successful "OpenKey" request
to HKCU\Software\Policies\Microsoft\Windows\Control Panel\Desktop. The next
entry "QueryKey" HKCU\Software\Policies\Microsoft\Windows\Control
Panel\Desktop\ScreenSaveActive fails with a result of BUFOVRFLOW. The third
and final trace entry of "CloseKey"
HKCU\Software\Policies\Microsoft\Windows\Control Panel\Desktop completes
successfully.
"Imran Koradia" wrote: Try using this instead:
Private Const SPI_SETSCREENSAVEACTIVE As Integer = 17 Private Const SPIF_SENDWININICHANGE As Integer = &H2 Private Const SPIF_UPDATEINIFILE As Integer = &H1
Return SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, iActiveFlag, _ 0, SPIF_SENDWININICHANGE Or SPIF_UPDATEINIFILE)
hope that helps.. Imran.
"Mike S." <Mike S.@discussions.microsoft.com> wrote in message news:41**********************************@microsof t.com... I'm using a SystemParametersInfo call to attempt to manage the screen saver. All I want to do is modify the ScreenSaveActive bit in the registry and have the OS recognize it (and occasionally set it back to -0-). Theoretically this should be easy to accomplish through the call shown below. If I trace the call with SysInternals (si)Registry Monitor I can see the call being made. Unfortunately in the si QueryValue for the key HKCU\Software\Policies\Microsoft\Windows\Control Panel\Desktop\ScreenSaveActive I'm getting a result of BUFOVRFLOW (which I assume is the trace tool unable to read the value). The value in the registry does not change.
We do have a forced screen saver GPO applied which I suspect may be causing the failure. I have checked registry permissions and all is ok on this key. I've used the SPIF_SENDWININICHANGE parameter with no luck. The following call is about as basic as I can get for troubleshooting this problem. Any ideas?
VB.net 1.1, Win2KPro (and XPPro) Also tried C++6.0 and VB6.0.
VB.net call
Private Declare Function SystemParametersInfo Lib "user32" _ Alias "SystemParametersInfoA" (ByVal uAction As Long, ByVal _ uParam As Long, ByVal lpvParam As Long, ByVal fuWinIni As _ Long) As Long
Private Function SetScreenSaver(ByVal Active As Boolean) As Long Dim lActiveFlag As Long = 0 If Active = True Then lActiveFlag = 1 Return = SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, lActiveFlag, 0, 0) End Function
-Mike
Ok..I'm officially stumped :-S
One reason for BUFOVRFLOW is that the key does not exist in the registry. On
my machine, I have the ScreenSaveActive key under HKCU\Control Panel\Desktop
which is different from whats showing in your registry trace. I'm not sure
if this has got anything to do with that. Its working fine on my machine -
the value changes from 1 to 0 and vice versa correctly.
Any viruses, trojans, etc? Corrupt registry, etc?
Can't think of anything else..sorry.
Imran.
"Mike S." <Mi***@discussions.microsoft.com> wrote in message
news:09**********************************@microsof t.com... Still no luck. The call looks like it's going through to user32.dll, but
it's not executing completely or properly. I am getting a return value of 0.
When I look at the registry trace I'm seeing a successful "OpenKey"
request to HKCU\Software\Policies\Microsoft\Windows\Control Panel\Desktop. The
next entry "QueryKey" HKCU\Software\Policies\Microsoft\Windows\Control Panel\Desktop\ScreenSaveActive fails with a result of BUFOVRFLOW. The
third and final trace entry of "CloseKey" HKCU\Software\Policies\Microsoft\Windows\Control Panel\Desktop completes successfully.
"Imran Koradia" wrote:
Try using this instead:
Private Const SPI_SETSCREENSAVEACTIVE As Integer = 17 Private Const SPIF_SENDWININICHANGE As Integer = &H2 Private Const SPIF_UPDATEINIFILE As Integer = &H1
Return SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, iActiveFlag, _ 0, SPIF_SENDWININICHANGE Or SPIF_UPDATEINIFILE)
hope that helps.. Imran.
"Mike S." <Mike S.@discussions.microsoft.com> wrote in message news:41**********************************@microsof t.com... I'm using a SystemParametersInfo call to attempt to manage the screen saver. All I want to do is modify the ScreenSaveActive bit in the registry
and have the OS recognize it (and occasionally set it back to -0-).
Theoretically this should be easy to accomplish through the call shown below. If I trace
the call with SysInternals (si)Registry Monitor I can see the call being
made. Unfortunately in the si QueryValue for the key HKCU\Software\Policies\Microsoft\Windows\Control Panel\Desktop\ScreenSaveActive I'm getting a result of BUFOVRFLOW
(which I assume is the trace tool unable to read the value). The value in the registry does not change.
We do have a forced screen saver GPO applied which I suspect may be causing the failure. I have checked registry permissions and all is ok on this key. I've used the SPIF_SENDWININICHANGE parameter with no luck. The
following call is about as basic as I can get for troubleshooting this problem.
Any ideas?
VB.net 1.1, Win2KPro (and XPPro) Also tried C++6.0 and VB6.0.
VB.net call
Private Declare Function SystemParametersInfo Lib "user32" _ Alias "SystemParametersInfoA" (ByVal uAction As Long, ByVal _ uParam As Long, ByVal lpvParam As Long, ByVal fuWinIni As _ Long) As Long
Private Function SetScreenSaver(ByVal Active As Boolean) As Long Dim lActiveFlag As Long = 0 If Active = True Then lActiveFlag = 1 Return = SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, lActiveFlag,
0, 0) End Function
-Mike
I have a feeling it may have to do with the application of the screen saver
GPO. Whatever is telling user32.dll to look at the policy location in the
registry may also be saying - do not modify. Obviously if a policy was
applied, you wouldn't want a local application to overwrite it. Conversely, I
can edit the registry directly without a problem but the OS doesn't get
notified until a logoff/logon or reboot (and then the policy is reapplied).
I've gone the other route and modified the registry directly and used
SendMessage to notify the OS about the change. Unfortunately it reads just
about every configuration entry in the registry except the screen saver one.
I've tested on several PC's (5), off domain, on domain, off policy, separate
location, etc. All of them incur the same issue. No known viruses, trojans or
corrupt registries on any of them.
Thanks for your help!
"Imran Koradia" wrote: Ok..I'm officially stumped :-S
One reason for BUFOVRFLOW is that the key does not exist in the registry. On my machine, I have the ScreenSaveActive key under HKCU\Control Panel\Desktop which is different from whats showing in your registry trace. I'm not sure if this has got anything to do with that. Its working fine on my machine - the value changes from 1 to 0 and vice versa correctly. Any viruses, trojans, etc? Corrupt registry, etc?
Can't think of anything else..sorry.
Imran.
"Mike S." <Mi***@discussions.microsoft.com> wrote in message news:09**********************************@microsof t.com... Still no luck. The call looks like it's going through to user32.dll, but it's not executing completely or properly. I am getting a return value of 0.
When I look at the registry trace I'm seeing a successful "OpenKey" request to HKCU\Software\Policies\Microsoft\Windows\Control Panel\Desktop. The next entry "QueryKey" HKCU\Software\Policies\Microsoft\Windows\Control Panel\Desktop\ScreenSaveActive fails with a result of BUFOVRFLOW. The third and final trace entry of "CloseKey" HKCU\Software\Policies\Microsoft\Windows\Control Panel\Desktop completes successfully.
"Imran Koradia" wrote:
Try using this instead:
Private Const SPI_SETSCREENSAVEACTIVE As Integer = 17 Private Const SPIF_SENDWININICHANGE As Integer = &H2 Private Const SPIF_UPDATEINIFILE As Integer = &H1
Return SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, iActiveFlag, _ 0, SPIF_SENDWININICHANGE Or SPIF_UPDATEINIFILE)
hope that helps.. Imran.
"Mike S." <Mike S.@discussions.microsoft.com> wrote in message news:41**********************************@microsof t.com... > I'm using a SystemParametersInfo call to attempt to manage the screen saver. > All I want to do is modify the ScreenSaveActive bit in the registry and have > the OS recognize it (and occasionally set it back to -0-). Theoretically this > should be easy to accomplish through the call shown below. If I trace the > call with SysInternals (si)Registry Monitor I can see the call being made. > Unfortunately in the si QueryValue for the key > HKCU\Software\Policies\Microsoft\Windows\Control > Panel\Desktop\ScreenSaveActive I'm getting a result of BUFOVRFLOW (which I > assume is the trace tool unable to read the value). The value in the registry > does not change. > > We do have a forced screen saver GPO applied which I suspect may be causing > the failure. I have checked registry permissions and all is ok on this key. > I've used the SPIF_SENDWININICHANGE parameter with no luck. The following > call is about as basic as I can get for troubleshooting this problem. Any > ideas? > > VB.net 1.1, Win2KPro (and XPPro) Also tried C++6.0 and VB6.0. > > > VB.net call > > Private Declare Function SystemParametersInfo Lib "user32" _ > Alias "SystemParametersInfoA" (ByVal uAction As Long, ByVal _ > uParam As Long, ByVal lpvParam As Long, ByVal fuWinIni As _ > Long) As Long > > Private Function SetScreenSaver(ByVal Active As Boolean) As Long > Dim lActiveFlag As Long = 0 > If Active = True Then lActiveFlag = 1 > Return = SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, lActiveFlag, 0, 0) > End Function > > > -Mike This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Mike S. |
last post by:
I'm using a SystemParametersInfo call to attempt to manage the screen saver.
All I want to do is modify the ScreenSaveActive bit in the registry and have
the OS recognize it (and occasionally set...
|
by: philippe.joliet |
last post by:
Hello,
I'm currently try to use the SystemParametersInfo function in a c#
environnement but I have a problem to use it with the action
SPI_SETWORKAREA
I've got this definition
private...
|
by: Dwight Trumbower |
last post by:
I need to disable the screen saver, due to an Excel "bug".
I thought I had the following code working, but now all I get is code 127.
I've searched the net and I don't see anything wrong with the...
|
by: Mohammad-Reza |
last post by:
In SystemParametersInfo API, type of its pvParam is PVOID.
I want to know what type I must use to both set and get of this api works
properly.
|
by: GTi |
last post by:
I need the csharp (C#) function for this API function:
SystemParametersInfo(SPI_GETWORKAREA, 0, &rc, 0);
Or must I pInvoke this (also)?
My biggest problem with C# is to find the C# function...
|
by: kenwhale |
last post by:
hi, all.
In my computer(windows2000 professional), I found this code doesn't
work!
SystemParametersInfo(0x2000/*SPI_GETFOREGROUNDLOCKTIMEOUT*/,0,&dwTimeOut,0))
;
The value of dwTimeOut...
|
by: Shamil Salakhetdinov |
last post by:
Hi All,
I did try by myself and I did search on google but I can't find any info on
how to use SystemParametersInfo Win32API in VB.NET
Any useful samples, hints, tips & tricks will be greatly...
|
by: David |
last post by:
Hi,
I'm trying to use SystemParametersInfo to get the desktop work area:
Private Declare Function SystemParametersInfo Lib "user32" Alias
"SystemParametersInfoA" (ByVal uAction As Integer,...
|
by: Scott David Daniels |
last post by:
There has been a bit of discussion about a way of providing test cases
in a test suite that _should_ work but don't. One of the rules has been
the test suite should be runnable and silent at every...
|
by: BigWilli |
last post by:
Hello, I want to change the keyboard language. Does anyone have an example code in VB6 for that? I know already from MSDN that it should be possible with the SystemParametersInfo and the...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |