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
27 AbortSystemShutdownW(LPCWSTR lpMachineName)
29 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
34 /**********************************************************************
35 * AbortSystemShutdownA
41 AbortSystemShutdownA(LPCSTR lpMachineName)
43 ANSI_STRING MachineNameA;
44 UNICODE_STRING MachineNameW;
48 RtlInitAnsiString(&MachineNameA, (LPSTR)lpMachineName);
49 Status = RtlAnsiStringToUnicodeString(&MachineNameW, &MachineNameA, TRUE);
50 if (STATUS_SUCCESS != Status) {
51 SetLastError(RtlNtStatusToDosError(Status));
54 rv = AbortSystemShutdownW(MachineNameW.Buffer);
55 RtlFreeAnsiString(&MachineNameA);
56 RtlFreeUnicodeString(&MachineNameW);
57 SetLastError(ERROR_SUCCESS);
62 /**********************************************************************
63 * InitiateSystemShutdownW
69 InitiateSystemShutdownW(
73 BOOL bForceAppsClosed,
74 BOOL bRebootAfterShutdown)
76 SHUTDOWN_ACTION Action = ShutdownNoReboot;
80 /* FIXME: remote machine shutdown not supported yet */
81 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
86 Status = NtShutdownSystem(Action);
87 SetLastError(RtlNtStatusToDosError(Status));
92 /**********************************************************************
93 * InitiateSystemShutdownA
99 InitiateSystemShutdownA(
103 BOOL bForceAppsClosed,
104 BOOL bRebootAfterShutdown)
106 ANSI_STRING MachineNameA;
107 ANSI_STRING MessageA;
108 UNICODE_STRING MachineNameW;
109 UNICODE_STRING MessageW;
115 RtlInitAnsiString(&MachineNameA, lpMachineName);
116 Status = RtlAnsiStringToUnicodeString(&MachineNameW, &MachineNameA, TRUE);
117 if (STATUS_SUCCESS != Status) {
118 RtlFreeAnsiString(&MachineNameA);
119 SetLastError(RtlNtStatusToDosError(Status));
124 RtlInitAnsiString(&MessageA, lpMessage);
125 Status = RtlAnsiStringToUnicodeString(&MessageW, &MessageA, TRUE);
126 if (STATUS_SUCCESS != Status) {
127 if (MachineNameW.Length) {
128 RtlFreeAnsiString(&MachineNameA);
129 RtlFreeUnicodeString(&MachineNameW);
131 RtlFreeAnsiString(&MessageA);
132 SetLastError(RtlNtStatusToDosError(Status));
136 rv = InitiateSystemShutdownW(
141 bRebootAfterShutdown);
142 LastError = GetLastError();
144 RtlFreeAnsiString(&MachineNameA);
145 RtlFreeUnicodeString(&MachineNameW);
148 RtlFreeAnsiString(&MessageA);
149 RtlFreeUnicodeString(&MessageW);
151 SetLastError(LastError);