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
;
114 RtlInitAnsiString(&MachineNameA
, lpMachineName
);
115 Status
= RtlAnsiStringToUnicodeString(&MachineNameW
, &MachineNameA
, TRUE
);
116 if (STATUS_SUCCESS
!= Status
)
118 SetLastError(RtlNtStatusToDosError(Status
));
125 RtlInitAnsiString(&MessageA
, lpMessage
);
126 Status
= RtlAnsiStringToUnicodeString(&MessageW
, &MessageA
, TRUE
);
127 if (STATUS_SUCCESS
!= Status
)
129 if (MachineNameW
.Length
)
131 RtlFreeUnicodeString(&MachineNameW
);
134 SetLastError(RtlNtStatusToDosError(Status
));
139 rv
= InitiateSystemShutdownW(MachineNameW
.Buffer
,
143 bRebootAfterShutdown
);
144 LastError
= GetLastError();
147 RtlFreeUnicodeString(&MachineNameW
);
152 RtlFreeUnicodeString(&MessageW
);
155 SetLastError(LastError
);
159 /******************************************************************************
160 * InitiateSystemShutdownExW [ADVAPI32.@]
162 * see InitiateSystemShutdownExA
165 InitiateSystemShutdownExW(LPWSTR lpMachineName
,
168 BOOL bForceAppsClosed
,
169 BOOL bRebootAfterShutdown
,