[SHELL32] CDrivesFolder: Implement the eject and disconnect menu items. CORE-13841
[reactos.git] / dll / win32 / wlnotify / schedsvc.c
1 /*
2 * PROJECT: ReactOS system libraries
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: dll/win32/wlnotify/schedsvc.c
5 * PURPOSE: Scheduler service logon notifications
6 * PROGRAMMER: Eric Kohl <eric.kohl@reactos.org>
7 */
8
9 #include "precomp.h"
10 #include <winsvc.h>
11
12 #define _NDEBUG
13 #include <debug.h>
14
15
16 VOID
17 WINAPI
18 SchedEventLogoff(
19 PWLX_NOTIFICATION_INFO pInfo)
20 {
21 SC_HANDLE hManager = NULL;
22 SC_HANDLE hService = NULL;
23 SERVICE_STATUS ServiceStatus;
24
25 DPRINT("SchedStartShellEvent\n");
26 DPRINT("Size: %lu\n", pInfo->Size);
27 DPRINT("Flags: %lx\n", pInfo->Flags);
28 DPRINT("UserName: %S\n", pInfo->UserName);
29 DPRINT("Domain: %S\n", pInfo->Domain);
30 DPRINT("WindowStation: %S\n", pInfo->WindowStation);
31 DPRINT("hToken: %p\n", pInfo->hToken);
32 DPRINT("hDesktop: %p\n", pInfo->hDesktop);
33 DPRINT("pStatusCallback: %p\n", pInfo->pStatusCallback);
34
35 hManager = OpenSCManagerW(NULL, NULL, SC_MANAGER_CONNECT);
36 if (hManager == NULL)
37 {
38 DPRINT1("OpenSCManagerW() failed (Error %lu)\n", GetLastError());
39 goto done;
40 }
41
42 hService = OpenServiceW(hManager, L"Schedule", SERVICE_USER_DEFINED_CONTROL);
43 if (hManager == NULL)
44 {
45 DPRINT1("OpenServiceW() failed (Error %lu)\n", GetLastError());
46 goto done;
47 }
48
49 if (!ControlService(hService, 129, &ServiceStatus))
50 {
51 DPRINT1("ControlService() failed (Error %lu)\n", GetLastError());
52 }
53
54 done:
55 if (hService != NULL)
56 CloseServiceHandle(hService);
57
58 if (hManager != NULL)
59 CloseServiceHandle(hManager);
60 }
61
62
63 VOID
64 WINAPI
65 SchedStartShell(
66 PWLX_NOTIFICATION_INFO pInfo)
67 {
68 SC_HANDLE hManager = NULL;
69 SC_HANDLE hService = NULL;
70 SERVICE_STATUS ServiceStatus;
71
72 DPRINT("SchedStartShellEvent\n");
73 DPRINT("Size: %lu\n", pInfo->Size);
74 DPRINT("Flags: %lx\n", pInfo->Flags);
75 DPRINT("UserName: %S\n", pInfo->UserName);
76 DPRINT("Domain: %S\n", pInfo->Domain);
77 DPRINT("WindowStation: %S\n", pInfo->WindowStation);
78 DPRINT("hToken: %p\n", pInfo->hToken);
79 DPRINT("hDesktop: %p\n", pInfo->hDesktop);
80 DPRINT("pStatusCallback: %p\n", pInfo->pStatusCallback);
81
82 hManager = OpenSCManagerW(NULL, NULL, SC_MANAGER_CONNECT);
83 if (hManager == NULL)
84 {
85 DPRINT1("OpenSCManagerW() failed (Error %lu)\n", GetLastError());
86 goto done;
87 }
88
89 hService = OpenServiceW(hManager, L"Schedule", SERVICE_USER_DEFINED_CONTROL);
90 if (hManager == NULL)
91 {
92 DPRINT1("OpenServiceW() failed (Error %lu)\n", GetLastError());
93 goto done;
94 }
95
96 if (!ControlService(hService, 128, &ServiceStatus))
97 {
98 DPRINT1("ControlService() failed (Error %lu)\n", GetLastError());
99 }
100
101 done:
102 if (hService != NULL)
103 CloseServiceHandle(hService);
104
105 if (hManager != NULL)
106 CloseServiceHandle(hManager);
107 }
108
109 /* EOF */