2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS system libraries
4 * FILE: dll/win32/advapi32/misc/shutdown.c
5 * PURPOSE: System shutdown functions
6 * PROGRAMMER: Lee Schroeder <spaceseel at gmail dot com>
11 WINE_DEFAULT_DEBUG_CHANNEL(advapi
);
15 /**********************************************************************
16 * AbortSystemShutdownW
21 AbortSystemShutdownW(LPCWSTR lpMachineName
)
23 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
28 /**********************************************************************
29 * AbortSystemShutdownA
34 AbortSystemShutdownA(LPCSTR lpMachineName
)
36 ANSI_STRING MachineNameA
;
37 UNICODE_STRING MachineNameW
;
41 RtlInitAnsiString(&MachineNameA
, (LPSTR
)lpMachineName
);
42 Status
= RtlAnsiStringToUnicodeString(&MachineNameW
, &MachineNameA
, TRUE
);
43 if (STATUS_SUCCESS
!= Status
)
45 SetLastError(RtlNtStatusToDosError(Status
));
49 rv
= AbortSystemShutdownW(MachineNameW
.Buffer
);
50 RtlFreeUnicodeString(&MachineNameW
);
51 SetLastError(ERROR_SUCCESS
);
55 /**********************************************************************
56 * InitiateSystemShutdownW
61 InitiateSystemShutdownW(LPWSTR lpMachineName
,
64 BOOL bForceAppsClosed
,
65 BOOL bRebootAfterShutdown
)
67 return InitiateSystemShutdownExW(lpMachineName
,
72 SHTDN_REASON_MAJOR_OTHER
|
73 SHTDN_REASON_MINOR_OTHER
|
74 SHTDN_REASON_FLAG_PLANNED
);
77 /**********************************************************************
78 * InitiateSystemShutdownA
84 InitiateSystemShutdownA(LPSTR lpMachineName
,
87 BOOL bForceAppsClosed
,
88 BOOL bRebootAfterShutdown
)
90 return InitiateSystemShutdownExA(lpMachineName
,
95 SHTDN_REASON_MAJOR_OTHER
|
96 SHTDN_REASON_MINOR_OTHER
|
97 SHTDN_REASON_FLAG_PLANNED
);
100 /******************************************************************************
101 * InitiateSystemShutdownExW [ADVAPI32.@]
106 InitiateSystemShutdownExW(LPWSTR lpMachineName
,
109 BOOL bForceAppsClosed
,
110 BOOL bRebootAfterShutdown
,
113 SHUTDOWN_ACTION Action
= ShutdownNoReboot
;
118 /* FIXME: remote machine shutdown not supported yet */
119 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
127 Status
= NtShutdownSystem(Action
);
128 SetLastError(RtlNtStatusToDosError(Status
));
132 /******************************************************************************
133 * InitiateSystemShutdownExA [ADVAPI32.@]
135 * see InitiateSystemShutdownExW
138 InitiateSystemShutdownExA(LPSTR lpMachineName
,
141 BOOL bForceAppsClosed
,
142 BOOL bRebootAfterShutdown
,
145 ANSI_STRING MachineNameA
, MessageA
;
146 UNICODE_STRING MachineNameW
, MessageW
;
151 MachineNameW
.Buffer
= NULL
;
152 MessageW
.Buffer
= NULL
;
156 RtlInitAnsiString(&MachineNameA
, lpMachineName
);
157 Status
= RtlAnsiStringToUnicodeString(&MachineNameW
, &MachineNameA
, TRUE
);
158 if (STATUS_SUCCESS
!= Status
)
160 if(MachineNameW
.Buffer
)
161 RtlFreeUnicodeString(&MachineNameW
);
163 SetLastError(RtlNtStatusToDosError(Status
));
170 RtlInitAnsiString(&MessageA
, lpMessage
);
171 Status
= RtlAnsiStringToUnicodeString(&MessageW
, &MessageA
, TRUE
);
172 if (STATUS_SUCCESS
!= Status
)
175 RtlFreeUnicodeString(&MessageW
);
177 SetLastError(RtlNtStatusToDosError(Status
));
182 rv
= InitiateSystemShutdownExW(MachineNameW
.Buffer
,
186 bRebootAfterShutdown
,
188 LastError
= GetLastError();
190 RtlFreeUnicodeString(&MachineNameW
);
193 RtlFreeUnicodeString(&MessageW
);
195 SetLastError(LastError
);
199 /******************************************************************************
200 * InitiateShutdownW [ADVAPI32.@]
205 InitiateShutdownW(LPWSTR lpMachineName
,
208 DWORD dwShutdownFlags
,
212 return ERROR_SUCCESS
;
215 /******************************************************************************
216 * InitiateShutdownA [ADVAPI32.@]
221 InitiateShutdownA(LPSTR lpMachineName
,
224 DWORD dwShutdownFlags
,
227 ANSI_STRING MachineNameA
, MessageA
;
228 UNICODE_STRING MachineNameW
, MessageW
;
233 MachineNameW
.Buffer
= NULL
;
234 MessageW
.Buffer
= NULL
;
238 RtlInitAnsiString(&MachineNameA
, lpMachineName
);
239 Status
= RtlAnsiStringToUnicodeString(&MachineNameW
, &MachineNameA
, TRUE
);
240 if (STATUS_SUCCESS
!= Status
)
242 if(MachineNameW
.Buffer
)
243 RtlFreeUnicodeString(&MachineNameW
);
245 SetLastError(RtlNtStatusToDosError(Status
));
252 RtlInitAnsiString(&MessageA
, lpMessage
);
253 Status
= RtlAnsiStringToUnicodeString(&MessageW
, &MessageA
, TRUE
);
254 if (STATUS_SUCCESS
!= Status
)
257 RtlFreeUnicodeString(&MessageW
);
259 SetLastError(RtlNtStatusToDosError(Status
));
264 rv
= InitiateShutdownW(MachineNameW
.Buffer
,
269 LastError
= GetLastError();
271 RtlFreeUnicodeString(&MachineNameW
);
274 RtlFreeUnicodeString(&MessageW
);
276 SetLastError(LastError
);