[SERVICES]

Service logon page:
- Handle the interactive service type flag.
- Change the service configuration in the apply function.

svn path=/trunk/; revision=71971
This commit is contained in:
Eric Kohl 2016-07-19 21:30:45 +00:00
parent 99c2c38f44
commit a60fc83f53

View file

@ -20,6 +20,7 @@ typedef struct _LOGONDATA
WCHAR szAccountName[64]; WCHAR szAccountName[64];
WCHAR szPassword1[64]; WCHAR szPassword1[64];
WCHAR szPassword2[64]; WCHAR szPassword2[64];
INT nInteractive;
BOOL bInitialized; BOOL bInitialized;
BOOL bLocalSystem; BOOL bLocalSystem;
BOOL bAccountChanged; BOOL bAccountChanged;
@ -43,6 +44,8 @@ SetControlStates(
if (bLocalSystem) if (bLocalSystem)
{ {
SendDlgItemMessageW(hwndDlg, IDC_LOGON_INTERACTIVE, BM_SETCHECK, (WPARAM)pLogonData->nInteractive, 0);
if (pLogonData->bInitialized == TRUE) if (pLogonData->bInitialized == TRUE)
{ {
GetDlgItemText(hwndDlg, IDC_LOGON_ACCOUNTNAME, pLogonData->szAccountName, 64); GetDlgItemText(hwndDlg, IDC_LOGON_ACCOUNTNAME, pLogonData->szAccountName, 64);
@ -56,6 +59,10 @@ SetControlStates(
} }
else else
{ {
if (pLogonData->bInitialized == TRUE)
pLogonData->nInteractive = SendDlgItemMessageW(hwndDlg, IDC_LOGON_INTERACTIVE, BM_GETCHECK, 0, 0);
SendDlgItemMessageW(hwndDlg, IDC_LOGON_INTERACTIVE, BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0);
SetDlgItemText(hwndDlg, IDC_LOGON_ACCOUNTNAME, pLogonData->szAccountName); SetDlgItemText(hwndDlg, IDC_LOGON_ACCOUNTNAME, pLogonData->szAccountName);
SetDlgItemText(hwndDlg, IDC_LOGON_PASSWORD1, pLogonData->szPassword1); SetDlgItemText(hwndDlg, IDC_LOGON_PASSWORD1, pLogonData->szPassword1);
SetDlgItemText(hwndDlg, IDC_LOGON_PASSWORD2, pLogonData->szPassword2); SetDlgItemText(hwndDlg, IDC_LOGON_PASSWORD2, pLogonData->szPassword2);
@ -65,10 +72,11 @@ SetControlStates(
} }
#if 0 static
BOOL BOOL
SetServiceAccount( SetServiceAccount(
LPWSTR lpServiceName, LPWSTR lpServiceName,
DWORD dwServiceType,
LPWSTR lpStartName, LPWSTR lpStartName,
LPWSTR lpPassword) LPWSTR lpPassword)
{ {
@ -91,7 +99,7 @@ SetServiceAccount(
if (hSc) if (hSc)
{ {
if (ChangeServiceConfigW(hSc, if (ChangeServiceConfigW(hSc,
SERVICE_NO_CHANGE, dwServiceType,
SERVICE_NO_CHANGE, SERVICE_NO_CHANGE,
SERVICE_NO_CHANGE, SERVICE_NO_CHANGE,
NULL, NULL,
@ -119,7 +127,6 @@ SetServiceAccount(
return bRet; return bRet;
} }
#endif
static static
@ -145,6 +152,7 @@ OnApply(
WCHAR szAccountName[64]; WCHAR szAccountName[64];
WCHAR szPassword1[64]; WCHAR szPassword1[64];
WCHAR szPassword2[64]; WCHAR szPassword2[64];
DWORD dwServiceType = SERVICE_NO_CHANGE;
BOOL bRet = TRUE; BOOL bRet = TRUE;
if (!pLogonData->bAccountChanged) if (!pLogonData->bAccountChanged)
@ -156,6 +164,13 @@ OnApply(
wcscpy(szAccountName, L"LocalSystem"); wcscpy(szAccountName, L"LocalSystem");
wcscpy(szPassword1, L""); wcscpy(szPassword1, L"");
wcscpy(szPassword2, L""); wcscpy(szPassword2, L"");
/* Handle the interactive flag */
dwServiceType = pLogonData->pServiceConfig->dwServiceType;
if (SendDlgItemMessageW(hwndDlg, IDC_LOGON_INTERACTIVE, BM_GETCHECK, 0, 0) == BST_CHECKED)
dwServiceType |= SERVICE_INTERACTIVE_PROCESS;
else
dwServiceType &= ~SERVICE_INTERACTIVE_PROCESS;
} }
else else
{ {
@ -175,23 +190,24 @@ OnApply(
ResourceMessageBox(GetModuleHandle(NULL), hwndDlg, MB_OK | MB_ICONWARNING, IDS_APPNAME, IDS_INVALID_PASSWORD); ResourceMessageBox(GetModuleHandle(NULL), hwndDlg, MB_OK | MB_ICONWARNING, IDS_APPNAME, IDS_INVALID_PASSWORD);
return FALSE; return FALSE;
} }
} }
#if 0
bRet = SetServiceAccount(pLogonData->pService->lpServiceName, bRet = SetServiceAccount(pLogonData->pService->lpServiceName,
dwServiceType,
szAccountName, szAccountName,
szPassword1); szPassword1);
if (bRet == FALSE) if (bRet == FALSE)
{ {
} }
#endif
if (bRet == TRUE) if (bRet == TRUE)
{
pLogonData->bAccountChanged = FALSE; pLogonData->bAccountChanged = FALSE;
}
return bRet; return bRet;
} }
@ -240,13 +256,17 @@ LogonPageProc(
if (pLogonData->pServiceConfig->lpServiceStartName == NULL || if (pLogonData->pServiceConfig->lpServiceStartName == NULL ||
_wcsicmp(pLogonData->pServiceConfig->lpServiceStartName, L"LocalSystem") == 0) _wcsicmp(pLogonData->pServiceConfig->lpServiceStartName, L"LocalSystem") == 0)
{ {
SendMessageW(GetDlgItem(hwndDlg, IDC_LOGON_SYSTEMACCOUNT), BM_SETCHECK, (WPARAM)BST_CHECKED, 0); SendDlgItemMessageW(hwndDlg, IDC_LOGON_SYSTEMACCOUNT, BM_SETCHECK, (WPARAM)BST_CHECKED, 0);
if (pLogonData->pServiceConfig->dwServiceType & SERVICE_INTERACTIVE_PROCESS) {
pLogonData->nInteractive = BST_CHECKED;
SendDlgItemMessageW(hwndDlg, IDC_LOGON_INTERACTIVE, BM_SETCHECK, (WPARAM)BST_CHECKED, 0);
}
SetControlStates(hwndDlg, pLogonData, TRUE); SetControlStates(hwndDlg, pLogonData, TRUE);
} }
else else
{ {
wcscpy(pLogonData->szAccountName, pLogonData->pServiceConfig->lpServiceStartName); wcscpy(pLogonData->szAccountName, pLogonData->pServiceConfig->lpServiceStartName);
SendMessageW(GetDlgItem(hwndDlg, IDC_LOGON_THISACCOUNT), BM_SETCHECK, (WPARAM)BST_CHECKED, 0); SendDlgItemMessageW(hwndDlg, IDC_LOGON_THISACCOUNT, BM_SETCHECK, (WPARAM)BST_CHECKED, 0);
SetControlStates(hwndDlg, pLogonData, FALSE); SetControlStates(hwndDlg, pLogonData, FALSE);
} }
} }
@ -291,6 +311,17 @@ LogonPageProc(
} }
break; break;
case IDC_LOGON_INTERACTIVE:
if (HIWORD(wParam) == BN_CLICKED)
{
if (pLogonData->bInitialized && pLogonData->bInitialized)
{
pLogonData->bAccountChanged = TRUE;
PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
}
}
break;
case IDC_LOGON_ACCOUNTNAME: case IDC_LOGON_ACCOUNTNAME:
case IDC_LOGON_PASSWORD1: case IDC_LOGON_PASSWORD1:
case IDC_LOGON_PASSWORD2: case IDC_LOGON_PASSWORD2: