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
14 #include <wine/debug.h>
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
) {
47 SetLastError(RtlNtStatusToDosError(Status
));
50 rv
= AbortSystemShutdownW(MachineNameW
.Buffer
);
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 SetLastError(RtlNtStatusToDosError(Status
));
117 RtlInitAnsiString(&MessageA
, lpMessage
);
118 Status
= RtlAnsiStringToUnicodeString(&MessageW
, &MessageA
, TRUE
);
119 if (STATUS_SUCCESS
!= Status
) {
120 if (MachineNameW
.Length
) {
121 RtlFreeUnicodeString(&MachineNameW
);
123 SetLastError(RtlNtStatusToDosError(Status
));
127 rv
= InitiateSystemShutdownW(
132 bRebootAfterShutdown
);
133 LastError
= GetLastError();
135 RtlFreeUnicodeString(&MachineNameW
);
138 RtlFreeUnicodeString(&MessageW
);
140 SetLastError(LastError
);
144 /******************************************************************************
145 * InitiateSystemShutdownExW [ADVAPI32.@]
147 * see InitiateSystemShutdownExA
149 BOOL WINAPI
InitiateSystemShutdownExW( LPWSTR lpMachineName
, LPWSTR lpMessage
,
150 DWORD dwTimeout
, BOOL bForceAppsClosed
, BOOL bRebootAfterShutdown
,
153 FIXME("%s %s %ld %d %d %ld\n", debugstr_w(lpMachineName
),
154 debugstr_w(lpMessage
), dwTimeout
, bForceAppsClosed
,
155 bRebootAfterShutdown
, dwReason
);