6dbe35540ee3e8c7d9a4a980f438de7c03fd78dc
[openafs.git] / src / WINNT / afssvrcfg / services_page.cpp
1 /*
2  * Copyright 2000, International Business Machines Corporation and others.
3  * All Rights Reserved.
4  * 
5  * This software has been released under the terms of the IBM Public
6  * License.  For details, see the LICENSE file in the top-level source
7  * directory or online at http://www.openafs.org/dl/license10.html
8  */
9
10 /*
11  * INCLUDES _________________________________________________________________
12  *
13  */
14 extern "C" {
15 #include <afs/param.h>
16 #include <afs/stds.h>
17 }
18
19 #include "afscfg.h"
20 #include "resource.h"
21 #include <stdio.h>
22 #include "admin_info_dlg.h"
23 #include "get_cur_config.h"
24
25
26 /*                                       
27  * DEFINITIONS _________________________________________________________________
28  *
29  */
30 static HWND hDlg = 0;
31 static BOOL bSettingScMachine;
32
33 // These indicate if the named service is currently running, and if the user wants it on
34 // or off.
35 static BOOL bFsRunning = FALSE;
36 static BOOL bFsOn = FALSE;
37
38 static BOOL bDbRunning = TRUE;
39 static BOOL bDbOn = FALSE;
40 static BOOL bDbParial = FALSE;
41
42 static BOOL bBakRunning = FALSE;
43 static BOOL bBakOn = FALSE;
44
45 static BOOL bScsRunning = FALSE;
46 static BOOL bScsOn = FALSE;
47
48 static BOOL bSccRunning = FALSE;
49 static BOOL bSccOn = FALSE;
50
51 static TCHAR szScMachine[MAX_MACHINE_NAME_LEN + 1];
52
53
54 /*
55  * PROTOTYPES _________________________________________________________________
56  *
57  */
58 // From config_server_page.cpp
59 BOOL Configure(HWND hParent, BOOL& bMustExit);
60
61 static void OnInitDialog(HWND hwndDlg);
62 static void ShowInitialConfig();
63 static void ShowServiceStates();
64 static void OnDbService();
65 static void OnBakService();
66 static void OnFsService();
67 static void OnScServer();
68 static void OnScClient();
69 static void CheckEnableSc();
70 static void EnableScMachine(BOOL bEnable = TRUE);
71 static void OnScMachineChange();
72 static void CheckEnableBak();
73 static void PrepareToConfig(CONFIG_STATE& state, BOOL bRunning, BOOL bOn);
74 static BOOL PrepareToConfig();
75 static void CheckEnableApply();
76
77
78 /*
79  * EXPORTED FUNCTIONS _________________________________________________________________
80  *
81  */
82
83 /*
84  * Dialog Proc _________________________________________________________________
85  *
86  */
87 BOOL CALLBACK ServicesPageDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
88 {
89         if (AfsAppLib_HandleHelp(IDD_SERVICES_PAGE, hwndDlg, uMsg, wParam, lParam))
90                 return TRUE;
91
92         switch (uMsg) {
93                 case WM_INITDIALOG:             OnInitDialog(hwndDlg);
94                                                                 break;
95  
96                 case WM_COMMAND:        switch (LOWORD(wParam)) {
97                                                                 case IDC_DB_SERVICE:    OnDbService();
98                                                                                                                 break;
99
100                                                                 case IDC_BK_SERVICE:    OnBakService();
101                                                                                                                 break;
102
103                                                                 case IDC_FS_SERVICE:    OnFsService();
104                                                                                                                 break;
105
106                                                                 case IDC_SCC:                   OnScClient();
107                                                                                                                 break;
108
109                                                                 case IDC_SCS:                   OnScServer();
110                                                                                                                 break;
111
112                                                                 case IDC_SC_MACHINE:    if (HIWORD(wParam) == EN_CHANGE) {
113                                                                                                                         OnScMachineChange();
114                                                                                                                 }
115                                                                                                                 break;
116                                                         
117                                                                 case IDAPPLY:                   PrepareToConfig();
118                                                                                                                 break;
119                                                         }
120                                                         break;
121         }
122
123         CheckEnableApply();
124
125         return FALSE;
126 }       
127
128
129 /*
130  * STATIC FUNCTIONS _________________________________________________________________
131  *
132  */
133 static void OnInitDialog(HWND hwndDlg)
134 {
135         hDlg = hwndDlg;
136
137         // Show the initial services config
138         ShowInitialConfig();
139         ShowServiceStates();
140
141         MakeBold(hDlg, IDC_DB_SERVICE);
142         MakeBold(hDlg, IDC_FS_SERVICE);
143         MakeBold(hDlg, IDC_BK_SERVICE);
144         MakeBold(hDlg, IDC_SCC);
145         MakeBold(hDlg, IDC_SCS);
146 }
147
148 static void EnableScMachine(BOOL bEnable)
149 {
150         SetEnable(hDlg, IDC_SC_MACHINE_LABEL, (ENABLE_STATE)bEnable);
151         SetEnable(hDlg, IDC_SC_MACHINE, (ENABLE_STATE)bEnable);
152
153         bSettingScMachine = TRUE;
154         SetWndText(hDlg, IDC_SC_MACHINE, bEnable ? szScMachine : TEXT(""));
155         bSettingScMachine = FALSE;
156 }
157
158 static void ShowInitialConfig()
159 {
160         // FS
161         bFsRunning = Configured(g_CfgData.configFS);
162         if (bFsRunning) {
163                 SetCheck(hDlg, IDC_FS_SERVICE);
164                 SetWndText(hDlg, IDC_FS_STATUS_MSG, IDS_FS_RUNNING);
165                 SetWndText(hDlg, IDC_FS_ACTION_MSG, IDS_FS_HOW_TO_STOP);
166         } else {
167                 SetCheck(hDlg, IDC_FS_SERVICE, FALSE);
168                 SetWndText(hDlg, IDC_FS_STATUS_MSG, IDS_FS_STOPPED);
169                 SetWndText(hDlg, IDC_FS_ACTION_MSG, IDS_FS_HOW_TO_RUN);
170         }
171
172         bFsOn = bFsRunning;
173
174     // DB
175         Set2State(hDlg, IDC_DB_SERVICE);
176         
177         bDbRunning = Configured(g_CfgData.configDB);
178         if (bDbRunning) {
179                 SetCheck(hDlg, IDC_DB_SERVICE);
180                 SetWndText(hDlg, IDC_DB_STATUS_MSG, IDS_DB_RUNNING);
181                 SetWndText(hDlg, IDC_DB_ACTION_MSG, IDS_DB_HOW_TO_STOP);
182         } else if (bDbParial) {
183                 SetCheck(hDlg, IDC_DB_SERVICE, BST_INDETERMINATE);
184                 SetWndText(hDlg, IDC_DB_STATUS_MSG, IDS_DB_PARTIAL_CONFIG);
185                 SetWndText(hDlg, IDC_DB_ACTION_MSG, IDS_DB_DETAILS);
186                 ShowWnd(hDlg, IDC_DB_DETAILS);
187                 Set3State(hDlg, IDC_DB_SERVICE);
188         } else {
189                 SetCheck(hDlg, IDC_DB_SERVICE, FALSE);
190                 SetWndText(hDlg, IDC_DB_STATUS_MSG, IDS_DB_STOPPED);
191                 SetWndText(hDlg, IDC_DB_ACTION_MSG, IDS_DB_HOW_TO_RUN);
192         }
193
194         bDbOn = bDbRunning;
195
196         // BK
197         bBakRunning = Configured(g_CfgData.configBak);
198         SetEnable(hDlg, IDC_BK_SERVICE, ES_ENABLE);
199         if (bBakRunning) {
200                 SetCheck(hDlg, IDC_BK_SERVICE);
201                 SetWndText(hDlg, IDC_BK_STATUS_MSG, IDS_BK_RUNNING);
202                 SetWndText(hDlg, IDC_BK_ACTION_MSG, IDS_BK_HOW_TO_STOP);
203         } else {
204                 SetCheck(hDlg, IDC_BK_SERVICE, FALSE);
205                 SetWndText(hDlg, IDC_BK_STATUS_MSG, IDS_BK_STOPPED);
206                 SetWndText(hDlg, IDC_BK_ACTION_MSG, IDS_BK_HOW_TO_RUN);
207         }
208
209         bBakOn = bBakRunning;
210
211         // SC Server
212         bScsRunning = Configured(g_CfgData.configSCS);
213         SetEnable(hDlg, IDC_SCS, ES_ENABLE);
214         if (bScsRunning) {
215                 SetCheck(hDlg, IDC_SCS);
216                 SetWndText(hDlg, IDC_SCS_ACTION_MSG, IDS_SCS_HOW_TO_STOP);
217         } else {
218                 SetCheck(hDlg, IDC_SCS, FALSE);
219                 SetWndText(hDlg, IDC_SCS_STATUS_MSG, IDS_SCS_STOPPED);
220                 SetWndText(hDlg, IDC_SCS_ACTION_MSG, IDS_SCS_HOW_TO_RUN);
221         }
222
223         bScsOn = bScsRunning;
224
225         // SC Client
226         bSccRunning = Configured(g_CfgData.configSCC);
227         SetEnable(hDlg, IDC_SCC, ES_ENABLE);
228         if (bSccRunning) {
229                 SetCheck(hDlg, IDC_SCC);
230                 SetWndText(hDlg, IDC_SCC_ACTION_MSG, IDS_SCC_HOW_TO_STOP);
231                 EnableScMachine();
232                 lstrcpy(szScMachine, g_CfgData.szSysControlMachine);
233         } else {
234                 SetCheck(hDlg, IDC_SCC, FALSE);
235                 SetWndText(hDlg, IDC_SCC_STATUS_MSG, IDS_SCC_STOPPED);
236                 SetWndText(hDlg, IDC_SCC_ACTION_MSG, IDS_SCC_HOW_TO_RUN);
237                 EnableScMachine(FALSE);
238         }
239
240         bSccOn = bSccRunning;
241 }
242
243 static void ShowServiceStates()
244 {
245         // FS
246         if (bFsOn) {
247                 if (bFsRunning)
248                         SetWndText(hDlg, IDC_FS_ACTION_MSG, IDS_FS_HOW_TO_STOP);
249                 else
250                         SetWndText(hDlg, IDC_FS_ACTION_MSG, IDS_FS_WILL_RUN);
251         } else {
252                 if (bFsRunning)
253                         SetWndText(hDlg, IDC_FS_ACTION_MSG, IDS_FS_WILL_STOP);
254                 else
255                         SetWndText(hDlg, IDC_FS_ACTION_MSG, IDS_FS_HOW_TO_RUN);
256         }
257
258         // DB
259         switch (GetButtonState(hDlg, IDC_DB_SERVICE)) {
260                 case BST_CHECKED:
261                                 if (bDbRunning)
262                                         SetWndText(hDlg, IDC_DB_ACTION_MSG, IDS_DB_HOW_TO_STOP);
263                                 else
264                                         SetWndText(hDlg, IDC_DB_ACTION_MSG, IDS_DB_WILL_RUN);
265                                 break;
266
267                 case BST_UNCHECKED:
268                                 if (bDbRunning)
269                                         SetWndText(hDlg, IDC_DB_ACTION_MSG, IDS_DB_WILL_STOP);
270                                 else
271                                         SetWndText(hDlg, IDC_DB_ACTION_MSG, IDS_DB_HOW_TO_RUN);
272                                 break;
273
274                 case BST_INDETERMINATE:
275                                 SetWndText(hDlg, IDC_DB_ACTION_MSG, IDS_DB_DETAILS);
276                                 break;
277         }
278
279         // For the ones below, in addition to setting the action message, we also
280         // set the status message.  This is because the status can change to the
281         // disabled state depending on how other servers are configured.  The
282         // servers before this cannot have their status change except by re-
283         // configuring them.
284
285         // BK
286         if (bDbOn) {
287                 if (IsButtonChecked(hDlg, IDC_BK_SERVICE)) {
288                         if (bBakRunning) {
289                                 SetWndText(hDlg, IDC_BK_STATUS_MSG, IDS_BK_RUNNING);
290                                 SetWndText(hDlg, IDC_BK_ACTION_MSG, IDS_BK_HOW_TO_STOP);
291                         } else {
292                                 SetWndText(hDlg, IDC_BK_STATUS_MSG, IDS_BK_STOPPED);
293                                 SetWndText(hDlg, IDC_BK_ACTION_MSG, IDS_BK_WILL_RUN);
294                         }
295                 } else {
296                         if (bBakRunning) {
297                                 SetWndText(hDlg, IDC_BK_STATUS_MSG, IDS_BK_RUNNING);
298                                 SetWndText(hDlg, IDC_BK_ACTION_MSG, IDS_BK_WILL_STOP);
299                         } else {
300                                 SetWndText(hDlg, IDC_BK_STATUS_MSG, IDS_BK_STOPPED);
301                                 SetWndText(hDlg, IDC_BK_ACTION_MSG, IDS_BK_HOW_TO_RUN);
302                         }
303                 }
304         }
305
306         CheckEnableBak();
307
308         // SC Server
309         if (bFsOn || bDbOn && !bSccOn) {
310                 if (bScsOn) {
311                         if (bScsRunning) {
312                                 SetWndText(hDlg, IDC_SCS_STATUS_MSG, IDS_SCS_RUNNING);
313                                 SetWndText(hDlg, IDC_SCS_ACTION_MSG, IDS_SCS_HOW_TO_STOP);
314                         } else {
315                                 SetWndText(hDlg, IDC_SCS_STATUS_MSG, IDS_SCS_STOPPED);
316                                 SetWndText(hDlg, IDC_SCS_ACTION_MSG, IDS_SCS_WILL_RUN);
317                         }
318                 } else {
319                         if (bScsRunning) {
320                                 SetWndText(hDlg, IDC_SCS_STATUS_MSG, IDS_SCS_RUNNING);
321                                 SetWndText(hDlg, IDC_SCS_ACTION_MSG, IDS_SCS_WILL_STOP);
322                         } else {
323                                 SetWndText(hDlg, IDC_SCS_STATUS_MSG, IDS_SCS_STOPPED);
324                                 SetWndText(hDlg, IDC_SCS_ACTION_MSG, IDS_SCS_HOW_TO_RUN);
325                         }
326                 }
327         }
328
329         // SC Client
330         if (bFsOn || bDbOn && !bScsOn) {
331                 if (bSccOn) {
332                         if (bSccRunning) {
333                                 SetWndText(hDlg, IDC_SCC_STATUS_MSG, IDS_SCC_RUNNING);
334                                 SetWndText(hDlg, IDC_SCC_ACTION_MSG, IDS_SCC_HOW_TO_STOP);
335                         } else {
336                                 SetWndText(hDlg, IDC_SCC_STATUS_MSG, IDS_SCC_STOPPED);
337                                 SetWndText(hDlg, IDC_SCC_ACTION_MSG, IDS_SCC_WILL_RUN);
338                         }
339                 } else {
340                         if (bSccRunning) {
341                                 SetWndText(hDlg, IDC_SCC_STATUS_MSG, IDS_SCC_RUNNING);
342                                 SetWndText(hDlg, IDC_SCC_ACTION_MSG, IDS_SCC_WILL_STOP);
343                         } else {
344                                 SetWndText(hDlg, IDC_SCC_STATUS_MSG, IDS_SCC_STOPPED);
345                                 SetWndText(hDlg, IDC_SCC_ACTION_MSG, IDS_SCC_HOW_TO_RUN);
346                         }
347                 }
348
349                 
350         }
351
352         CheckEnableSc();
353 }
354
355 static void OnDbService()
356 {
357         bDbOn = GetButtonState(hDlg, IDC_DB_SERVICE) == BST_CHECKED;
358
359         CheckEnableBak();
360         CheckEnableSc();
361
362         ShowServiceStates();
363 }
364
365 static void OnBakService()
366 {
367         bBakOn = !bBakOn;
368
369         ShowServiceStates();
370 }
371
372 static void OnFsService()
373 {
374         bFsOn = !bFsOn;
375
376         CheckEnableSc();
377
378         ShowServiceStates();
379 }
380
381 static void CheckEnableBak()
382 {
383         // Enable/disable bk service based on db service.
384         if (!bDbOn) {
385                 SetCheck(hDlg, IDC_BK_SERVICE, FALSE);
386                 SetEnable(hDlg, IDC_BK_SERVICE, ES_DISABLE);
387                 SetWndText(hDlg, IDC_BK_STATUS_MSG, IDS_BK_DISABLED);
388                 SetWndText(hDlg, IDC_BK_ACTION_MSG, IDS_BK_ENABLE);
389         } else {
390                 SetCheck(hDlg, IDC_BK_SERVICE, bBakOn);
391                 SetEnable(hDlg, IDC_BK_SERVICE, ES_ENABLE);
392         }
393 }
394
395 static void CheckEnableSc()
396 {
397         BOOL bSccEnable;
398         UINT uiSccStatusMsg;
399         UINT uiSccActionMsg;
400         BOOL bScsEnable;
401         UINT uiScsStatusMsg;
402         UINT uiScsActionMsg;
403
404         // Disable SCS and SCC?
405         if (!bFsOn && !bDbOn) {
406                 bScsEnable = FALSE;
407                 uiScsStatusMsg = IDS_SC_DISABLED;
408                 uiScsActionMsg = IDS_SC_ENABLE;
409
410                 bSccEnable = FALSE;
411                 uiSccStatusMsg = IDS_SC_DISABLED;
412                 uiSccActionMsg = IDS_SC_ENABLE;
413                 // Disable SCS?
414         } else if (bSccOn) {
415                 bScsEnable = FALSE;
416                 uiScsStatusMsg = IDS_SC_DISABLED;
417                 uiScsActionMsg = IDS_SCS_ENABLE;
418                 // Disable SCC
419         } else if (bScsOn) {
420                 bSccEnable = FALSE;
421                 uiSccStatusMsg = IDS_SC_DISABLED;
422                 uiSccActionMsg = IDS_SCC_ENABLE;
423         }               
424
425         // Enable the sc server GUI
426         if (bScsEnable) {
427                 SetEnable(hDlg, IDC_SCS, ES_ENABLE);
428                 SetCheck(hDlg, IDC_SCS, bScsOn);
429         } else {        // Disable the sc server gui
430                 SetEnable(hDlg, IDC_SCS, ES_DISABLE);
431                 SetCheck(hDlg, IDC_SCS, FALSE);
432                 SetWndText(hDlg, IDC_SCS_STATUS_MSG, uiScsStatusMsg);
433                 SetWndText(hDlg, IDC_SCS_ACTION_MSG, uiScsActionMsg);
434         }
435
436         // Enable the sc client GUI
437         if (bSccEnable) {
438                 SetEnable(hDlg, IDC_SCC, ES_ENABLE);
439                 SetCheck(hDlg, IDC_SCC, bSccOn);
440                 EnableScMachine(bSccOn);
441         } else {        // Disable the sc client gui
442                 SetEnable(hDlg, IDC_SCC, ES_DISABLE);
443                 SetCheck(hDlg, IDC_SCC, FALSE);
444                 SetWndText(hDlg, IDC_SCC_STATUS_MSG, uiSccStatusMsg);
445                 SetWndText(hDlg, IDC_SCC_ACTION_MSG, uiSccActionMsg);
446                 EnableScMachine(FALSE);
447         }
448 }
449
450 static void OnScServer()
451 {
452         bScsOn = !bScsOn;
453
454         ShowServiceStates();
455 }
456
457 static void OnScClient()
458 {
459         bSccOn = !bSccOn;
460
461         ShowServiceStates();
462 }
463
464 static void OnScMachineChange()
465 {
466         if (!bSettingScMachine && IsButtonChecked(hDlg, IDC_SCC))
467                 GetWndText(hDlg, IDC_SC_MACHINE, szScMachine, sizeof(szScMachine) / sizeof(szScMachine[0]));
468 }
469
470 static BOOL PrepareToConfig(CONFIG_STATE& state, BOOL bRunning, BOOL bOn, UINT uiCtrlID)
471 {
472         BOOL bEnabled = IsWindowEnabled(GetDlgItem(hDlg, uiCtrlID));
473
474         if (bRunning && (!bOn || !bEnabled))
475                 state = CS_UNCONFIGURE;
476         else if (!bRunning && (bOn && bEnabled))
477                 state = CS_CONFIGURE;
478
479     return (state == CS_UNCONFIGURE) || (state == CS_CONFIGURE);
480 }
481
482 static BOOL PrepareToConfig()
483 {
484     BOOL bMustExit = FALSE;
485
486     // Use a local copy of the config info to decide what should be configured
487     // or unconfigured.  We do this so that if the user cancels for some reason,
488     // the real config state will still be what the user expects (what was
489     // previously read from the system plus the user's changes).
490         CONFIG_STATE configFS = g_CfgData.configFS;     // File server
491         CONFIG_STATE configDB = g_CfgData.configDB;     // Database server
492         CONFIG_STATE configBak = g_CfgData.configBak;   // Backup server
493         CONFIG_STATE configSCS = g_CfgData.configSCS;   // System Control server
494         CONFIG_STATE configSCC = g_CfgData.configSCC;   // System Control client
495
496     BOOL bWorkToDo = FALSE;
497
498         bWorkToDo |= PrepareToConfig(configFS, bFsRunning, bFsOn, IDC_FS_SERVICE);
499         bWorkToDo |= PrepareToConfig(configDB, bDbRunning, bDbOn, IDC_DB_SERVICE);
500     bWorkToDo |= PrepareToConfig(configBak, bBakRunning, bBakOn, IDC_BK_SERVICE);
501         bWorkToDo |= PrepareToConfig(configSCS, bScsRunning, bScsOn, IDC_SCS);
502         bWorkToDo |= PrepareToConfig(configSCC, bSccRunning, bSccOn, IDC_SCC);
503
504     // If there is nothing to do, then just return TRUE.
505     if (!bWorkToDo)
506         return TRUE;
507
508         // If we are unconfiguring the last DB server:
509         //              1) Warn user and ask for confirmation
510         //              2) Unconfigure all other servers that are running on this machine
511         //              3) Tell them (after unconfiguring) that they must run the Wizard if they
512         //                 wish to reconfigure the machine, then exit the program.
513         if (configDB == CS_UNCONFIGURE) {
514                 if (g_CfgData.bLastDBServer) {
515                         int nChoice = MsgBox(hDlg, IDS_LAST_DB_SERVER, GetAppTitleID(), MB_YESNO | MB_ICONEXCLAMATION);
516                         if (nChoice == IDNO)
517                                 return FALSE;
518         
519                         // Make sure these all get unconfigured as well.  If they are not configured, then
520                         // nothing bad will happen because the config calls are idempotent.
521                         configFS = CS_UNCONFIGURE;
522                         configBak = CS_UNCONFIGURE;
523                         configSCS = CS_UNCONFIGURE;
524                         configSCC = CS_UNCONFIGURE;
525                 }
526         }
527
528         // Get additional needed information from the user
529         GET_ADMIN_INFO_OPTIONS eOptions;
530         BOOL bDB = (ShouldConfig(configDB) || ShouldUnconfig(configDB));
531
532         // Use this as our default
533         eOptions = GAIO_LOGIN_ONLY;
534
535         // If we already have a sys control machine, then we don't need to ask for it
536         if (ShouldConfig(configSCC)) {
537                 if (szScMachine[0] == 0) {
538                         ShowWarning(hDlg, IDS_MUST_ENTER_SCS_NAME);
539                         return FALSE;
540                 }
541                 lstrcpy(g_CfgData.szSysControlMachine, szScMachine);
542         } else if (bDB && !g_CfgData.bLastDBServer) {
543         // We need to know the name of the SCM machine.  Are we the SCM machine?
544         if (bScsRunning)
545             lstrcpy(g_CfgData.szSysControlMachine, g_CfgData.szHostname);
546         else
547                     eOptions = GAIO_GET_SCS;
548     }
549
550     // If doing a login only and the admin info is reusable
551     if ((eOptions != GAIO_LOGIN_ONLY) || !g_CfgData.bReuseAdminInfo) {
552         if (!GetAdminInfo(hDlg, eOptions))
553                 return FALSE;
554
555         // Use the admin info to get new handles
556         if (!GetHandles(hDlg))
557             return FALSE;
558     }
559
560     // Now that we are ready to configure, copy our local config info
561     // into the structure that the config engine uses.
562         g_CfgData.configFS = configFS;
563     g_CfgData.configDB = configDB;
564         g_CfgData.configBak = configBak;
565         g_CfgData.configSCS = configSCS;
566         g_CfgData.configSCC = configSCC;
567
568         // Configure the server
569         BOOL bConfigSucceeded = Configure(hDlg, bMustExit);
570     if (bConfigSucceeded) {
571         if (bMustExit) {
572                     PostQuitMessage(0);
573                     return TRUE;
574             }
575         g_CfgData.bReuseAdminInfo = TRUE;
576     } else
577         g_CfgData.szAdminPW[0] = 0;
578
579         // Get current config status
580         BOOL bCanceled = FALSE;
581         DWORD dwStatus = GetCurrentConfig(hDlg, bCanceled);
582         if (dwStatus || bCanceled) {
583                 if (!bCanceled)
584                         ErrorDialog(dwStatus, IDS_CONFIG_CHECK_FAILED);
585         }
586
587         // Show the initial services config
588         ShowInitialConfig();
589         ShowServiceStates();
590
591         return TRUE;
592 }
593
594 static void CheckEnableApply()
595 {
596         BOOL bEnable = FALSE;
597         
598         bEnable = (bFsRunning != bFsOn) || (bDbRunning != bDbOn) || (bBakRunning != bBakOn) ||
599                                 (bScsRunning != bScsOn) || (bSccRunning != bSccOn);
600
601         if (bEnable)
602                 PropSheet_Changed(GetParent(hDlg), hDlg);
603         else
604                 PropSheet_UnChanged(GetParent(hDlg), hDlg);
605 }
606
607