28 typedef struct _RESTART_SERVICE_CONTEXT
31 SC_HANDLE ServiceHandle;
46 _In_ SC_HANDLE ServiceHandle
51 context.ServiceItem = ServiceItem;
52 context.ServiceHandle = ServiceHandle;
53 context.Starting =
FALSE;
54 context.DisableTimer =
FALSE;
74 if (uMsg == WM_INITDIALOG)
77 SetProp(hwndDlg, L
"Context", (HANDLE)context);
83 if (uMsg == WM_DESTROY)
84 RemoveProp(hwndDlg, L
"Context");
104 SetTimer(hwndDlg, 1, 250, NULL);
108 EndDialog(hwndDlg, IDCANCEL);
114 switch (LOWORD(wParam))
118 EndDialog(hwndDlg, IDCANCEL);
126 if (wParam == 1 && !context->DisableTimer)
128 SERVICE_STATUS serviceStatus;
130 if (QueryServiceStatus(context->ServiceHandle, &serviceStatus))
132 if (!context->Starting && serviceStatus.dwCurrentState == SERVICE_STOPPED)
138 context->DisableTimer =
TRUE;
142 context->DisableTimer =
FALSE;
143 context->Starting =
TRUE;
147 EndDialog(hwndDlg, IDCANCEL);
150 else if (context->Starting && serviceStatus.dwCurrentState == SERVICE_RUNNING)
152 EndDialog(hwndDlg, IDOK);