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
18 /**********************************************************************
19 * AbortSystemShutdownW
24 AbortSystemShutdownW(LPCWSTR lpMachineName
)
26 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
31 /**********************************************************************
32 * 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
)
48 SetLastError(RtlNtStatusToDosError(Status
));
52 rv
= AbortSystemShutdownW(MachineNameW
.Buffer
);
53 RtlFreeUnicodeString(&MachineNameW
);
54 SetLastError(ERROR_SUCCESS
);
59 /**********************************************************************
60 * InitiateSystemShutdownW
65 InitiateSystemShutdownW(LPWSTR lpMachineName
,
68 BOOL bForceAppsClosed
,
69 BOOL bRebootAfterShutdown
)
71 SHUTDOWN_ACTION Action
= ShutdownNoReboot
;
76 /* FIXME: remote machine shutdown not supported yet */
77 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
85 Status
= NtShutdownSystem(Action
);
86 SetLastError(RtlNtStatusToDosError(Status
));
91 /**********************************************************************
92 * InitiateSystemShutdownA
98 InitiateSystemShutdownA(LPSTR lpMachineName
,
101 BOOL bForceAppsClosed
,
102 BOOL bRebootAfterShutdown
)
104 ANSI_STRING MachineNameA
;
105 ANSI_STRING MessageA
;
106 UNICODE_STRING MachineNameW
;
107 UNICODE_STRING MessageW
;
112 MachineNameW
.Buffer
= NULL
;
113 MessageW
.Buffer
= NULL
;
117 RtlInitAnsiString(&MachineNameA
, lpMachineName
);
118 Status
= RtlAnsiStringToUnicodeString(&MachineNameW
, &MachineNameA
, TRUE
);
119 if (STATUS_SUCCESS
!= Status
)
121 SetLastError(RtlNtStatusToDosError(Status
));
128 RtlInitAnsiString(&MessageA
, lpMessage
);
129 Status
= RtlAnsiStringToUnicodeString(&MessageW
, &MessageA
, TRUE
);
130 if (STATUS_SUCCESS
!= Status
)
132 if (MachineNameW
.Buffer
)
134 RtlFreeUnicodeString(&MachineNameW
);
137 SetLastError(RtlNtStatusToDosError(Status
));
142 rv
= InitiateSystemShutdownW(MachineNameW
.Buffer
,
146 bRebootAfterShutdown
);
147 LastError
= GetLastError();
150 RtlFreeUnicodeString(&MachineNameW
);
155 RtlFreeUnicodeString(&MessageW
);
158 SetLastError(LastError
);
162 /******************************************************************************
163 * InitiateSystemShutdownExW [ADVAPI32.@]
165 * see InitiateSystemShutdownExA
168 InitiateSystemShutdownExW(LPWSTR lpMachineName
,
171 BOOL bForceAppsClosed
,
172 BOOL bRebootAfterShutdown
,
180 InitiateSystemShutdownExA(LPSTR lpMachineName
,
183 BOOL bForceAppsClosed
,
184 BOOL bRebootAfterShutdown
,