3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS system libraries
5 * FILE: lib/advapi32/misc/shutdown.c
6 * PURPOSE: System shutdown functions
7 * PROGRAMMER: Emanuele Aliberti
15 #define NTOS_MODE_USER
20 /**********************************************************************
21 * AbortSystemShutdownW
25 AbortSystemShutdownW(LPCWSTR lpMachineName)
27 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
32 /**********************************************************************
33 * AbortSystemShutdownA
37 AbortSystemShutdownA(LPCSTR lpMachineName)
39 ANSI_STRING MachineNameA;
40 UNICODE_STRING MachineNameW;
44 RtlInitAnsiString(&MachineNameA, (LPSTR)lpMachineName);
45 Status = RtlAnsiStringToUnicodeString(&MachineNameW, &MachineNameA, TRUE);
46 if (STATUS_SUCCESS != Status) {
47 SetLastError(RtlNtStatusToDosError(Status));
50 rv = AbortSystemShutdownW(MachineNameW.Buffer);
51 RtlFreeAnsiString(&MachineNameA);
52 RtlFreeUnicodeString(&MachineNameW);
53 SetLastError(ERROR_SUCCESS);
58 /**********************************************************************
59 * InitiateSystemShutdownW
63 InitiateSystemShutdownW(
67 BOOL bForceAppsClosed,
68 BOOL bRebootAfterShutdown)
70 SHUTDOWN_ACTION Action = ShutdownNoReboot;
74 /* FIXME: remote machine shutdown not supported yet */
75 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
80 Status = NtShutdownSystem(Action);
81 SetLastError(RtlNtStatusToDosError(Status));
86 /**********************************************************************
87 * InitiateSystemShutdownA
91 InitiateSystemShutdownA(
95 BOOL bForceAppsClosed,
96 BOOL bRebootAfterShutdown)
98 ANSI_STRING MachineNameA;
100 UNICODE_STRING MachineNameW;
101 UNICODE_STRING MessageW;
107 RtlInitAnsiString(&MachineNameA, lpMachineName);
108 Status = RtlAnsiStringToUnicodeString(&MachineNameW, &MachineNameA, TRUE);
109 if (STATUS_SUCCESS != Status) {
110 RtlFreeAnsiString(&MachineNameA);
111 SetLastError(RtlNtStatusToDosError(Status));
116 RtlInitAnsiString(&MessageA, lpMessage);
117 Status = RtlAnsiStringToUnicodeString(&MessageW, &MessageA, TRUE);
118 if (STATUS_SUCCESS != Status) {
119 if (MachineNameW.Length) {
120 RtlFreeAnsiString(&MachineNameA);
121 RtlFreeUnicodeString(&MachineNameW);
123 RtlFreeAnsiString(&MessageA);
124 SetLastError(RtlNtStatusToDosError(Status));
128 rv = InitiateSystemShutdownW(
133 bRebootAfterShutdown);
134 LastError = GetLastError();
136 RtlFreeAnsiString(&MachineNameA);
137 RtlFreeUnicodeString(&MachineNameW);
140 RtlFreeAnsiString(&MessageA);
141 RtlFreeUnicodeString(&MessageW);
143 SetLastError(LastError);