Re: SystemParametersInfo Failing in VB.net
From: Mike S. (MikeS_at_discussions.microsoft.com)
Date: 10/04/04
- Next message: tpenrod: "Intellisense not working"
- Previous message: tpenrod: "Intellisense (go to Definition) not working"
- In reply to: Imran Koradia: "Re: SystemParametersInfo Failing in VB.net"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 4 Oct 2004 15:39:03 -0700
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." <MikeS@discussions.microsoft.com> wrote in message
> news:0935C2B6-26CB-4E22-B860-609A00AB0160@microsoft.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:415E97EE-208D-424F-8CDF-13DA03AD3CC0@microsoft.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
> > >
> > >
> > >
>
>
>
- Next message: tpenrod: "Intellisense not working"
- Previous message: tpenrod: "Intellisense (go to Definition) not working"
- In reply to: Imran Koradia: "Re: SystemParametersInfo Failing in VB.net"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|