Использование SPI_SETSCREENSAVESECURE не включает защиту паролем для заставки Windows

Когда я запускаю следующую строку кода, защита моей заставки паролем не включается. Я также проверил ключ реестра, который используется для управления защитой паролем, и он также не переключается.

    If SystemParametersInfo(SPI_SETSCREENSAVESECURE, 1, nullVar, SPIF_SENDWININICHANGE) = 0 Then
        Throw New WindowsDotHException(ErrorToString(Err.LastDllError()) & " (Error number " & Err.LastDllError & ")")
    End If

Контекст:

WindosDotHException - мой способ обработки кодов ошибок из SystemParametersInfo.

    ' Signatures for unmanaged calls
<DllImport("user32.dll", CharSet:=CharSet.Auto)> _
Private Shared Function SystemParametersInfo(uAction As Integer, uParam As Integer, ByRef lpvParam As Integer, flags As Integer) As Boolean
End Function

<DllImport("user32.dll", CharSet:=CharSet.Auto)> _
Private Shared Function SystemParametersInfo(uAction As Integer, uParam As Integer, ByRef lpvParam As Boolean, flags As Integer) As Boolean
End Function

<DllImport("user32.dll", CharSet:=CharSet.Auto)> _
Private Shared Function PostMessage(hWnd As IntPtr, wMsg As Integer, wParam As Integer, lParam As Integer) As Integer
End Function

<DllImport("user32.dll", CharSet:=CharSet.Auto)> _
Private Shared Function OpenDesktop(hDesktop As String, Flags As Integer, Inherit As Boolean, DesiredAccess As UInteger) As IntPtr
End Function

<DllImport("user32.dll", CharSet:=CharSet.Auto)> _
Private Shared Function CloseDesktop(hDesktop As IntPtr) As Boolean
End Function

<DllImport("user32.dll", CharSet:=CharSet.Auto)> _
Private Shared Function EnumDesktopWindows(hDesktop As IntPtr, callback As EnumDesktopWindowsProc, lParam As IntPtr) As Boolean
End Function

<DllImport("user32.dll", CharSet:=CharSet.Auto)> _
Private Shared Function IsWindowVisible(hWnd As IntPtr) As Boolean
End Function

<DllImport("user32.dll", CharSet:=CharSet.Auto)> _
Public Shared Function GetForegroundWindow() As IntPtr
End Function

' Callbacks
Private Delegate Function EnumDesktopWindowsProc(hDesktop As IntPtr, lParam As IntPtr) As Boolean

' Constants
Private Const SPI_GETSCREENSAVERACTIVE As Integer = 16
Private Const SPI_SETSCREENSAVERACTIVE As Integer = 17
Private Const SPI_GETSCREENSAVERTIMEOUT As Integer = 14
Private Const SPI_SETSCREENSAVERTIMEOUT As Integer = 15
Private Const SPI_GETSCREENSAVERRUNNING As Integer = 114
Private Const SPIF_SENDWININICHANGE As Integer = 2
Private Const SPI_SETSCREENSAVESECURE As Integer = 119

Private Const DESKTOP_WRITEOBJECTS As UInteger = &H80
Private Const DESKTOP_READOBJECTS As UInteger = &H1
Private Const WM_CLOSE As Integer = 16

Операционная система: Windows 7 32-разрядная версия

Язык: VB .Net

Вещи, которые я пробовал:

  • Перезагрузка компьютера
  • выход из системы и повторный вход после выполнения кода

Что я могу сделать, чтобы включить защиту паролем в Windows 7?

0 ответов

Другие вопросы по тегам