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
17 /**********************************************************************
18 * AbortSystemShutdownW
23 AbortSystemShutdownW(LPCWSTR lpMachineName
)
25 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
30 /**********************************************************************
31 * AbortSystemShutdownA
36 AbortSystemShutdownA(LPCSTR lpMachineName
)
38 ANSI_STRING MachineNameA
;
39 UNICODE_STRING MachineNameW
;
43 RtlInitAnsiString(&MachineNameA
, (LPSTR
)lpMachineName
);
44 Status
= RtlAnsiStringToUnicodeString(&MachineNameW
, &MachineNameA
, TRUE
);
45 if (STATUS_SUCCESS
!= Status
) {
46 SetLastError(RtlNtStatusToDosError(Status
));
49 rv
= AbortSystemShutdownW(MachineNameW
.Buffer
);
50 RtlFreeAnsiString(&MachineNameA
);
51 RtlFreeUnicodeString(&MachineNameW
);
52 SetLastError(ERROR_SUCCESS
);
57 /**********************************************************************
58 * 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
93 InitiateSystemShutdownA(
97 BOOL bForceAppsClosed
,
98 BOOL bRebootAfterShutdown
)
100 ANSI_STRING MachineNameA
;
101 ANSI_STRING MessageA
;
102 UNICODE_STRING MachineNameW
;
103 UNICODE_STRING MessageW
;
109 RtlInitAnsiString(&MachineNameA
, lpMachineName
);
110 Status
= RtlAnsiStringToUnicodeString(&MachineNameW
, &MachineNameA
, TRUE
);
111 if (STATUS_SUCCESS
!= Status
) {
112 RtlFreeAnsiString(&MachineNameA
);
113 SetLastError(RtlNtStatusToDosError(Status
));
118 RtlInitAnsiString(&MessageA
, lpMessage
);
119 Status
= RtlAnsiStringToUnicodeString(&MessageW
, &MessageA
, TRUE
);
120 if (STATUS_SUCCESS
!= Status
) {
121 if (MachineNameW
.Length
) {
122 RtlFreeAnsiString(&MachineNameA
);
123 RtlFreeUnicodeString(&MachineNameW
);
125 RtlFreeAnsiString(&MessageA
);
126 SetLastError(RtlNtStatusToDosError(Status
));
130 rv
= InitiateSystemShutdownW(
135 bRebootAfterShutdown
);
136 LastError
= GetLastError();
138 RtlFreeAnsiString(&MachineNameA
);
139 RtlFreeUnicodeString(&MachineNameW
);
142 RtlFreeAnsiString(&MessageA
);
143 RtlFreeUnicodeString(&MessageW
);
145 SetLastError(LastError
);