[USRMGR] Implement "Require user name and password on system startup." (#7887)

This implements the tickbox along with the associated code required for it to work.

CORE-11371
This commit is contained in:
Petru Răzvan 2025-04-17 14:55:31 +03:00 committed by GitHub
parent be56c5c328
commit 7026466324
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
19 changed files with 95 additions and 19 deletions

View file

@ -17,7 +17,7 @@ BEGIN
PUSHBUTTON "&Přidat...", IDC_USERS_ADD, 87, 98, 50, 14 PUSHBUTTON "&Přidat...", IDC_USERS_ADD, 87, 98, 50, 14
PUSHBUTTON "&Odebrat", IDC_USERS_REMOVE, 141, 98, 50, 14 PUSHBUTTON "&Odebrat", IDC_USERS_REMOVE, 141, 98, 50, 14
PUSHBUTTON "&Vlastnosti", IDC_USERS_PROPERTIES, 195, 98, 50, 14 PUSHBUTTON "&Vlastnosti", IDC_USERS_PROPERTIES, 195, 98, 50, 14
AUTOCHECKBOX "Vyžadovat uživatelské jméno a heslo při spuštění sytému.", IDC_USERS_STARTUP_REQUIRE, 10, 118, 200, 14, WS_DISABLED AUTOCHECKBOX "Vyžadovat uživatelské jméno a heslo při spuštění sytému.", IDC_USERS_STARTUP_REQUIRE, 10, 118, 200, 14
PUSHBUTTON "Reset Password", IDC_USERS_RESET, 165, 200, 80, 14, WS_DISABLED PUSHBUTTON "Reset Password", IDC_USERS_RESET, 165, 200, 80, 14, WS_DISABLED
END END

View file

@ -12,7 +12,7 @@ BEGIN
PUSHBUTTON "&Hinzufügen...", IDC_USERS_ADD, 87, 98, 50, 14 PUSHBUTTON "&Hinzufügen...", IDC_USERS_ADD, 87, 98, 50, 14
PUSHBUTTON "&Entfernen", IDC_USERS_REMOVE, 141, 98, 50, 14 PUSHBUTTON "&Entfernen", IDC_USERS_REMOVE, 141, 98, 50, 14
PUSHBUTTON "E&igenschaften", IDC_USERS_PROPERTIES, 195, 98, 50, 14 PUSHBUTTON "E&igenschaften", IDC_USERS_PROPERTIES, 195, 98, 50, 14
AUTOCHECKBOX "Benut&zer müssen Benutzername und Kennwort zum Starten eingeben", IDC_USERS_STARTUP_REQUIRE, 10, 118, 235, 14, WS_DISABLED AUTOCHECKBOX "Benut&zer müssen Benutzername und Kennwort zum Starten eingeben", IDC_USERS_STARTUP_REQUIRE, 10, 118, 235, 14
PUSHBUTTON "Kenn&wort zurücksetzen", IDC_USERS_RESET, 165, 200, 80, 14, WS_DISABLED PUSHBUTTON "Kenn&wort zurücksetzen", IDC_USERS_RESET, 165, 200, 80, 14, WS_DISABLED
END END

View file

@ -12,7 +12,7 @@ BEGIN
PUSHBUTTON "A&dd...", IDC_USERS_ADD, 87, 98, 50, 14 PUSHBUTTON "A&dd...", IDC_USERS_ADD, 87, 98, 50, 14
PUSHBUTTON "&Remove", IDC_USERS_REMOVE, 141, 98, 50, 14 PUSHBUTTON "&Remove", IDC_USERS_REMOVE, 141, 98, 50, 14
PUSHBUTTON "Pr&operties", IDC_USERS_PROPERTIES, 195, 98, 50, 14 PUSHBUTTON "Pr&operties", IDC_USERS_PROPERTIES, 195, 98, 50, 14
AUTOCHECKBOX "Re&quire user name and password on system startup.", IDC_USERS_STARTUP_REQUIRE, 10, 118, 200, 14, WS_DISABLED AUTOCHECKBOX "Re&quire user name and password on system startup.", IDC_USERS_STARTUP_REQUIRE, 10, 118, 200, 14
PUSHBUTTON "R&eset Password", IDC_USERS_RESET, 165, 200, 80, 14, WS_DISABLED PUSHBUTTON "R&eset Password", IDC_USERS_RESET, 165, 200, 80, 14, WS_DISABLED
END END

View file

@ -14,7 +14,7 @@ BEGIN
PUSHBUTTON "A&gregar..", IDC_USERS_ADD, 87, 98, 50, 14 PUSHBUTTON "A&gregar..", IDC_USERS_ADD, 87, 98, 50, 14
PUSHBUTTON "&Quitar", IDC_USERS_REMOVE, 141, 98, 50, 14 PUSHBUTTON "&Quitar", IDC_USERS_REMOVE, 141, 98, 50, 14
PUSHBUTTON "Pr&opiedades", IDC_USERS_PROPERTIES, 195, 98, 50, 14 PUSHBUTTON "Pr&opiedades", IDC_USERS_PROPERTIES, 195, 98, 50, 14
AUTOCHECKBOX "Forzar la entrada de usuario y contraseña al iniciar el sistema.", IDC_USERS_STARTUP_REQUIRE, 10, 118, 200, 14, WS_DISABLED AUTOCHECKBOX "Forzar la entrada de usuario y contraseña al iniciar el sistema.", IDC_USERS_STARTUP_REQUIRE, 10, 118, 200, 14
PUSHBUTTON "Reiniciar contraseña", IDC_USERS_RESET, 165, 200, 80, 14, WS_DISABLED PUSHBUTTON "Reiniciar contraseña", IDC_USERS_RESET, 165, 200, 80, 14, WS_DISABLED
END END

View file

@ -12,7 +12,7 @@ BEGIN
PUSHBUTTON "A&jouter...", IDC_USERS_ADD, 87, 98, 50, 14 PUSHBUTTON "A&jouter...", IDC_USERS_ADD, 87, 98, 50, 14
PUSHBUTTON "&Retirer", IDC_USERS_REMOVE, 141, 98, 50, 14 PUSHBUTTON "&Retirer", IDC_USERS_REMOVE, 141, 98, 50, 14
PUSHBUTTON "Pr&opriétés", IDC_USERS_PROPERTIES, 195, 98, 50, 14 PUSHBUTTON "Pr&opriétés", IDC_USERS_PROPERTIES, 195, 98, 50, 14
AUTOCHECKBOX "Nécessite un identifiant et mot de passe au démarrage du système.", IDC_USERS_STARTUP_REQUIRE, 10, 118, 235, 14, WS_DISABLED AUTOCHECKBOX "Nécessite un identifiant et mot de passe au démarrage du système.", IDC_USERS_STARTUP_REQUIRE, 10, 118, 235, 14
PUSHBUTTON "Réinitialiser le &mot de passe", IDC_USERS_RESET, 145, 200, 100, 14, WS_DISABLED PUSHBUTTON "Réinitialiser le &mot de passe", IDC_USERS_RESET, 145, 200, 100, 14, WS_DISABLED
END END

View file

@ -12,7 +12,7 @@ BEGIN
PUSHBUTTON "A&dd...", IDC_USERS_ADD, 87, 98, 50, 14 PUSHBUTTON "A&dd...", IDC_USERS_ADD, 87, 98, 50, 14
PUSHBUTTON "&Remove", IDC_USERS_REMOVE, 141, 98, 50, 14 PUSHBUTTON "&Remove", IDC_USERS_REMOVE, 141, 98, 50, 14
PUSHBUTTON "Pr&operties", IDC_USERS_PROPERTIES, 195, 98, 50, 14 PUSHBUTTON "Pr&operties", IDC_USERS_PROPERTIES, 195, 98, 50, 14
AUTOCHECKBOX "Require user name and password on system startup.", IDC_USERS_STARTUP_REQUIRE, 10, 118, 200, 14, WS_DISABLED AUTOCHECKBOX "Require user name and password on system startup.", IDC_USERS_STARTUP_REQUIRE, 10, 118, 200, 14
PUSHBUTTON "Reset Password", IDC_USERS_RESET, 165, 200, 80, 14, WS_DISABLED PUSHBUTTON "Reset Password", IDC_USERS_RESET, 165, 200, 80, 14, WS_DISABLED
END END

View file

@ -12,7 +12,7 @@ BEGIN
PUSHBUTTON "&Tambah...", IDC_USERS_ADD, 87, 98, 50, 14 PUSHBUTTON "&Tambah...", IDC_USERS_ADD, 87, 98, 50, 14
PUSHBUTTON "&Hapus", IDC_USERS_REMOVE, 141, 98, 50, 14 PUSHBUTTON "&Hapus", IDC_USERS_REMOVE, 141, 98, 50, 14
PUSHBUTTON "Pr&operti", IDC_USERS_PROPERTIES, 195, 98, 50, 14 PUSHBUTTON "Pr&operti", IDC_USERS_PROPERTIES, 195, 98, 50, 14
AUTOCHECKBOX "&Butuh nama pengguna dan kata sandi saat memulai sistem.", IDC_USERS_STARTUP_REQUIRE, 10, 118, 200, 14, WS_DISABLED AUTOCHECKBOX "&Butuh nama pengguna dan kata sandi saat memulai sistem.", IDC_USERS_STARTUP_REQUIRE, 10, 118, 200, 14
PUSHBUTTON "R&eset Kata Sandi", IDC_USERS_RESET, 165, 200, 80, 14, WS_DISABLED PUSHBUTTON "R&eset Kata Sandi", IDC_USERS_RESET, 165, 200, 80, 14, WS_DISABLED
END END

View file

@ -12,7 +12,7 @@ BEGIN
PUSHBUTTON "N&uovo...", IDC_USERS_ADD, 87, 98, 50, 14 PUSHBUTTON "N&uovo...", IDC_USERS_ADD, 87, 98, 50, 14
PUSHBUTTON "&Rimuovi", IDC_USERS_REMOVE, 141, 98, 50, 14 PUSHBUTTON "&Rimuovi", IDC_USERS_REMOVE, 141, 98, 50, 14
PUSHBUTTON "Pr&oprietà", IDC_USERS_PROPERTIES, 195, 98, 50, 14 PUSHBUTTON "Pr&oprietà", IDC_USERS_PROPERTIES, 195, 98, 50, 14
AUTOCHECKBOX "Richiesta la password all'avvio del sistema.", IDC_USERS_STARTUP_REQUIRE, 10, 118, 200, 14, WS_DISABLED AUTOCHECKBOX "Richiesta la password all'avvio del sistema.", IDC_USERS_STARTUP_REQUIRE, 10, 118, 200, 14
PUSHBUTTON "Resetta Password", IDC_USERS_RESET, 165, 200, 80, 14, WS_DISABLED PUSHBUTTON "Resetta Password", IDC_USERS_RESET, 165, 200, 80, 14, WS_DISABLED
END END

View file

@ -12,7 +12,7 @@ BEGIN
PUSHBUTTON "追加(&D)...", IDC_USERS_ADD, 87, 98, 50, 14 PUSHBUTTON "追加(&D)...", IDC_USERS_ADD, 87, 98, 50, 14
PUSHBUTTON "削除(&R)", IDC_USERS_REMOVE, 141, 98, 50, 14 PUSHBUTTON "削除(&R)", IDC_USERS_REMOVE, 141, 98, 50, 14
PUSHBUTTON "プロパティ(&O)", IDC_USERS_PROPERTIES, 195, 98, 50, 14 PUSHBUTTON "プロパティ(&O)", IDC_USERS_PROPERTIES, 195, 98, 50, 14
AUTOCHECKBOX "ユーザー名とパスワードをシステム開始時に要求します(&Q)", IDC_USERS_STARTUP_REQUIRE, 10, 118, 200, 14, WS_DISABLED AUTOCHECKBOX "ユーザー名とパスワードをシステム開始時に要求します(&Q)", IDC_USERS_STARTUP_REQUIRE, 10, 118, 200, 14
PUSHBUTTON "パスワードのリセット(&E)", IDC_USERS_RESET, 165, 200, 80, 14, WS_DISABLED PUSHBUTTON "パスワードのリセット(&E)", IDC_USERS_RESET, 165, 200, 80, 14, WS_DISABLED
END END

View file

@ -22,7 +22,7 @@ BEGIN
PUSHBUTTON "&Dodaj...", IDC_USERS_ADD, 87, 98, 50, 14 PUSHBUTTON "&Dodaj...", IDC_USERS_ADD, 87, 98, 50, 14
PUSHBUTTON "&Usuń", IDC_USERS_REMOVE, 141, 98, 50, 14 PUSHBUTTON "&Usuń", IDC_USERS_REMOVE, 141, 98, 50, 14
PUSHBUTTON "Właściw&ości", IDC_USERS_PROPERTIES, 195, 98, 50, 14 PUSHBUTTON "Właściw&ości", IDC_USERS_PROPERTIES, 195, 98, 50, 14
AUTOCHECKBOX "Wymagaj nazwy użytkownika i hasła przy starcie systemu.", IDC_USERS_STARTUP_REQUIRE, 10, 118, 200, 14, WS_DISABLED AUTOCHECKBOX "Wymagaj nazwy użytkownika i hasła przy starcie systemu.", IDC_USERS_STARTUP_REQUIRE, 10, 118, 200, 14
PUSHBUTTON "Resetuj hasło", IDC_USERS_RESET, 165, 200, 80, 14, WS_DISABLED PUSHBUTTON "Resetuj hasło", IDC_USERS_RESET, 165, 200, 80, 14, WS_DISABLED
END END

View file

@ -19,7 +19,7 @@ BEGIN
PUSHBUTTON "&Adicionar...", IDC_USERS_ADD, 87, 98, 50, 14 PUSHBUTTON "&Adicionar...", IDC_USERS_ADD, 87, 98, 50, 14
PUSHBUTTON "&Remover", IDC_USERS_REMOVE, 141, 98, 50, 14 PUSHBUTTON "&Remover", IDC_USERS_REMOVE, 141, 98, 50, 14
PUSHBUTTON "Pr&opriedades", IDC_USERS_PROPERTIES, 195, 98, 50, 14 PUSHBUTTON "Pr&opriedades", IDC_USERS_PROPERTIES, 195, 98, 50, 14
AUTOCHECKBOX "Requer um nome de utilizador e uma palavra-passe ao iniciar o sistema.", IDC_USERS_STARTUP_REQUIRE, 10, 118, 240, 14, WS_DISABLED AUTOCHECKBOX "Requer um nome de utilizador e uma palavra-passe ao iniciar o sistema.", IDC_USERS_STARTUP_REQUIRE, 10, 118, 240, 14
PUSHBUTTON "Redefinir palavra-passe", IDC_USERS_RESET, 165, 200, 80, 14, WS_DISABLED PUSHBUTTON "Redefinir palavra-passe", IDC_USERS_RESET, 165, 200, 80, 14, WS_DISABLED
END END

View file

@ -14,7 +14,7 @@ BEGIN
PUSHBUTTON "A&dăugare…", IDC_USERS_ADD, 87, 98, 50, 14 PUSHBUTTON "A&dăugare…", IDC_USERS_ADD, 87, 98, 50, 14
PUSHBUTTON "&Eliminare…", IDC_USERS_REMOVE, 141, 98, 50, 14 PUSHBUTTON "&Eliminare…", IDC_USERS_REMOVE, 141, 98, 50, 14
PUSHBUTTON "&Proprietăți…", IDC_USERS_PROPERTIES, 195, 98, 50, 14 PUSHBUTTON "&Proprietăți…", IDC_USERS_PROPERTIES, 195, 98, 50, 14
AUTOCHECKBOX "S&olicită la pornirea sistemului numele de utilizator și parola.", IDC_USERS_STARTUP_REQUIRE, 10, 118, 200, 14, WS_DISABLED AUTOCHECKBOX "S&olicită la pornirea sistemului numele de utilizator și parola.", IDC_USERS_STARTUP_REQUIRE, 10, 118, 200, 14
PUSHBUTTON "Destit&uie parola", IDC_USERS_RESET, 165, 200, 80, 14, WS_DISABLED PUSHBUTTON "Destit&uie parola", IDC_USERS_RESET, 165, 200, 80, 14, WS_DISABLED
END END

View file

@ -12,7 +12,7 @@ BEGIN
PUSHBUTTON "Добавить...", IDC_USERS_ADD, 87, 98, 50, 14 PUSHBUTTON "Добавить...", IDC_USERS_ADD, 87, 98, 50, 14
PUSHBUTTON "Удалить", IDC_USERS_REMOVE, 141, 98, 50, 14 PUSHBUTTON "Удалить", IDC_USERS_REMOVE, 141, 98, 50, 14
PUSHBUTTON "Свойства", IDC_USERS_PROPERTIES, 195, 98, 50, 14 PUSHBUTTON "Свойства", IDC_USERS_PROPERTIES, 195, 98, 50, 14
AUTOCHECKBOX "Требуется имя пользователя и пароль при загрузке системы", IDC_USERS_STARTUP_REQUIRE, 10, 118, 220, 14, WS_DISABLED AUTOCHECKBOX "Требуется имя пользователя и пароль при загрузке системы", IDC_USERS_STARTUP_REQUIRE, 10, 118, 220, 14
PUSHBUTTON "Сбросить пароль", IDC_USERS_RESET, 165, 200, 80, 14, WS_DISABLED PUSHBUTTON "Сбросить пароль", IDC_USERS_RESET, 165, 200, 80, 14, WS_DISABLED
END END

View file

@ -14,7 +14,7 @@ BEGIN
PUSHBUTTON "&Ekle...", IDC_USERS_ADD, 87, 98, 50, 14 PUSHBUTTON "&Ekle...", IDC_USERS_ADD, 87, 98, 50, 14
PUSHBUTTON "&Sil", IDC_USERS_REMOVE, 141, 98, 50, 14 PUSHBUTTON "&Sil", IDC_USERS_REMOVE, 141, 98, 50, 14
PUSHBUTTON "Ö&zellikler", IDC_USERS_PROPERTIES, 195, 98, 50, 14 PUSHBUTTON "Ö&zellikler", IDC_USERS_PROPERTIES, 195, 98, 50, 14
AUTOCHECKBOX "Sistemi &başlatmada kullanıcı adı ve parola gerektir.", IDC_USERS_STARTUP_REQUIRE, 10, 118, 200, 14, WS_DISABLED AUTOCHECKBOX "Sistemi &başlatmada kullanıcı adı ve parola gerektir.", IDC_USERS_STARTUP_REQUIRE, 10, 118, 200, 14
PUSHBUTTON "&Parolayı Değiştir", IDC_USERS_RESET, 165, 200, 80, 14, WS_DISABLED PUSHBUTTON "&Parolayı Değiştir", IDC_USERS_RESET, 165, 200, 80, 14, WS_DISABLED
END END

View file

@ -12,7 +12,7 @@ BEGIN
PUSHBUTTON "A&dd...", IDC_USERS_ADD, 87, 98, 50, 14 PUSHBUTTON "A&dd...", IDC_USERS_ADD, 87, 98, 50, 14
PUSHBUTTON "&Remove", IDC_USERS_REMOVE, 141, 98, 50, 14 PUSHBUTTON "&Remove", IDC_USERS_REMOVE, 141, 98, 50, 14
PUSHBUTTON "Pr&operties", IDC_USERS_PROPERTIES, 195, 98, 50, 14 PUSHBUTTON "Pr&operties", IDC_USERS_PROPERTIES, 195, 98, 50, 14
AUTOCHECKBOX "Require user name and password on system startup.", IDC_USERS_STARTUP_REQUIRE, 10, 118, 200, 14, WS_DISABLED AUTOCHECKBOX "Require user name and password on system startup.", IDC_USERS_STARTUP_REQUIRE, 10, 118, 200, 14
PUSHBUTTON "Reset Password", IDC_USERS_RESET, 165, 200, 80, 14, WS_DISABLED PUSHBUTTON "Reset Password", IDC_USERS_RESET, 165, 200, 80, 14, WS_DISABLED
END END

View file

@ -21,7 +21,7 @@ BEGIN
PUSHBUTTON "添加...(&D)", IDC_USERS_ADD, 87, 98, 50, 14 PUSHBUTTON "添加...(&D)", IDC_USERS_ADD, 87, 98, 50, 14
PUSHBUTTON "删除(&R)", IDC_USERS_REMOVE, 141, 98, 50, 14 PUSHBUTTON "删除(&R)", IDC_USERS_REMOVE, 141, 98, 50, 14
PUSHBUTTON "属性(&O)", IDC_USERS_PROPERTIES, 195, 98, 50, 14 PUSHBUTTON "属性(&O)", IDC_USERS_PROPERTIES, 195, 98, 50, 14
AUTOCHECKBOX "在系统启动时需要用户名和密码。", IDC_USERS_STARTUP_REQUIRE, 10, 118, 200, 14, WS_DISABLED AUTOCHECKBOX "在系统启动时需要用户名和密码。", IDC_USERS_STARTUP_REQUIRE, 10, 118, 200, 14
PUSHBUTTON "重置密码", IDC_USERS_RESET, 165, 200, 80, 14, WS_DISABLED PUSHBUTTON "重置密码", IDC_USERS_RESET, 165, 200, 80, 14, WS_DISABLED
END END

View file

@ -20,7 +20,7 @@ BEGIN
PUSHBUTTON "新增(&D)...", IDC_USERS_ADD, 87, 98, 50, 14 PUSHBUTTON "新增(&D)...", IDC_USERS_ADD, 87, 98, 50, 14
PUSHBUTTON "移除(&R)", IDC_USERS_REMOVE, 141, 98, 50, 14 PUSHBUTTON "移除(&R)", IDC_USERS_REMOVE, 141, 98, 50, 14
PUSHBUTTON "內容(&O)", IDC_USERS_PROPERTIES, 195, 98, 50, 14 PUSHBUTTON "內容(&O)", IDC_USERS_PROPERTIES, 195, 98, 50, 14
AUTOCHECKBOX "在系統啟動時需要使用者名稱和密碼。(&Q)", IDC_USERS_STARTUP_REQUIRE, 10, 118, 200, 14, WS_DISABLED AUTOCHECKBOX "在系統啟動時需要使用者名稱和密碼。(&Q)", IDC_USERS_STARTUP_REQUIRE, 10, 118, 200, 14
PUSHBUTTON "重設密碼(&E)", IDC_USERS_RESET, 165, 200, 80, 14, WS_DISABLED PUSHBUTTON "重設密碼(&E)", IDC_USERS_RESET, 165, 200, 80, 14, WS_DISABLED
END END

View file

@ -20,7 +20,7 @@ BEGIN
PUSHBUTTON "新增(&D)...", IDC_USERS_ADD, 87, 98, 50, 14 PUSHBUTTON "新增(&D)...", IDC_USERS_ADD, 87, 98, 50, 14
PUSHBUTTON "移除(&R)", IDC_USERS_REMOVE, 141, 98, 50, 14 PUSHBUTTON "移除(&R)", IDC_USERS_REMOVE, 141, 98, 50, 14
PUSHBUTTON "內容(&O)", IDC_USERS_PROPERTIES, 195, 98, 50, 14 PUSHBUTTON "內容(&O)", IDC_USERS_PROPERTIES, 195, 98, 50, 14
AUTOCHECKBOX "在系統啟動時需要使用者名稱和密碼。(&Q)", IDC_USERS_STARTUP_REQUIRE, 10, 118, 200, 14, WS_DISABLED AUTOCHECKBOX "在系統啟動時需要使用者名稱和密碼。(&Q)", IDC_USERS_STARTUP_REQUIRE, 10, 118, 200, 14
PUSHBUTTON "重設密碼(&E)", IDC_USERS_RESET, 165, 200, 80, 14, WS_DISABLED PUSHBUTTON "重設密碼(&E)", IDC_USERS_RESET, 165, 200, 80, 14, WS_DISABLED
END END

View file

@ -15,6 +15,7 @@
*/ */
#include "usrmgr.h" #include "usrmgr.h"
#include <winreg.h>
typedef struct _USER_DATA typedef struct _USER_DATA
{ {
@ -650,6 +651,44 @@ UpdateUserProperties(HWND hwndDlg)
NetApiBufferFree(pUserInfo); NetApiBufferFree(pUserInfo);
} }
VOID OnToggleRequireLogon(_In_ HWND hwndDlg)
{
HKEY hKey;
LONG lResult;
BOOL bIsChecked;
PCWSTR pszAutoAdminLogonValue;
lResult = RegCreateKeyExW(HKEY_LOCAL_MACHINE,
L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon",
0,
NULL,
REG_OPTION_NON_VOLATILE,
KEY_SET_VALUE,
NULL,
&hKey,
NULL);
if (lResult != ERROR_SUCCESS)
{
ERR("OnToggleRequireLogon: Failed to open or create Winlogon registry key. Error code: %ld\n", lResult);
return;
}
bIsChecked = IsDlgButtonChecked(hwndDlg, IDC_USERS_STARTUP_REQUIRE) == BST_CHECKED;
pszAutoAdminLogonValue = bIsChecked ? L"0" : L"1";
lResult = RegSetValueExW(hKey,
L"AutoAdminLogon",
0,
REG_SZ,
(const BYTE*)pszAutoAdminLogonValue,
2 * sizeof(WCHAR));
if (lResult != ERROR_SUCCESS)
{
ERR("OnToggleRequireLogon: Failed to set AutoAdminLogon registry value. Error code: %ld\n", lResult);
}
RegCloseKey(hKey);
}
INT_PTR CALLBACK INT_PTR CALLBACK
UsersPageProc(HWND hwndDlg, UsersPageProc(HWND hwndDlg,
@ -666,16 +705,50 @@ UsersPageProc(HWND hwndDlg,
switch (uMsg) switch (uMsg)
{ {
case WM_INITDIALOG: case WM_INITDIALOG:
pUserData = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(USER_DATA)); {
LONG lResult;
HKEY hKey;
WCHAR szAutoAdminLogonValue[2];
DWORD dwType;
DWORD dwSize = sizeof(szAutoAdminLogonValue);
BOOL bRequireLogon = TRUE;
pUserData = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*pUserData));
SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pUserData); SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pUserData);
pUserData->hPopupMenu = LoadMenu(hApplet, MAKEINTRESOURCE(IDM_POPUP_USER)); pUserData->hPopupMenu = LoadMenu(hApplet, MAKEINTRESOURCE(IDM_POPUP_USER));
OnInitDialog(hwndDlg); OnInitDialog(hwndDlg);
lResult = RegOpenKeyExW(HKEY_LOCAL_MACHINE,
L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon",
0, KEY_READ, &hKey);
if (lResult != ERROR_SUCCESS)
{
CheckDlgButton(hwndDlg, IDC_USERS_STARTUP_REQUIRE, BST_CHECKED);
break;
}
lResult = RegQueryValueExW(hKey,
L"AutoAdminLogon",
NULL,
&dwType,
(LPBYTE)szAutoAdminLogonValue,
&dwSize);
RegCloseKey(hKey);
if (lResult == ERROR_SUCCESS && dwType == REG_SZ &&
wcscmp(szAutoAdminLogonValue, L"1") == 0)
{
bRequireLogon = FALSE;
}
CheckDlgButton(hwndDlg, IDC_USERS_STARTUP_REQUIRE, bRequireLogon ? BST_CHECKED : BST_UNCHECKED);
SetMenuDefaultItem(GetSubMenu(pUserData->hPopupMenu, 1), SetMenuDefaultItem(GetSubMenu(pUserData->hPopupMenu, 1),
IDM_USER_PROPERTIES, IDM_USER_PROPERTIES,
FALSE); FALSE);
break; break;
}
case WM_COMMAND: case WM_COMMAND:
switch (LOWORD(wParam)) switch (LOWORD(wParam))
@ -705,6 +778,9 @@ UsersPageProc(HWND hwndDlg,
UpdateUserProperties(hwndDlg); UpdateUserProperties(hwndDlg);
} }
break; break;
case IDC_USERS_STARTUP_REQUIRE:
OnToggleRequireLogon(hwndDlg);
break;
} }
break; break;