mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 17:52:56 +00:00
[ADVAPI32]
- Pre-implement InitiateSystemShutdownExW. - Cosmetic formatting code (by me). Patch by Lee Schroeder. See CORE-6613 for more details. CORE-6613 #comment Committed shutdown.c. svn path=/trunk/; revision=57546
This commit is contained in:
parent
8c8afce2e4
commit
c3e3d4003d
1 changed files with 33 additions and 15 deletions
|
@ -10,8 +10,6 @@
|
||||||
#include <advapi32.h>
|
#include <advapi32.h>
|
||||||
WINE_DEFAULT_DEBUG_CHANNEL(advapi);
|
WINE_DEFAULT_DEBUG_CHANNEL(advapi);
|
||||||
|
|
||||||
#define USZ {0,0,0}
|
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* AbortSystemShutdownW
|
* AbortSystemShutdownW
|
||||||
*
|
*
|
||||||
|
@ -28,7 +26,7 @@ AbortSystemShutdownW(LPCWSTR lpMachineName)
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* AbortSystemShutdownA
|
* AbortSystemShutdownA
|
||||||
*
|
*
|
||||||
* @unimplemented
|
* see AbortSystemShutdownW
|
||||||
*/
|
*/
|
||||||
BOOL WINAPI
|
BOOL WINAPI
|
||||||
AbortSystemShutdownA(LPCSTR lpMachineName)
|
AbortSystemShutdownA(LPCSTR lpMachineName)
|
||||||
|
@ -42,8 +40,8 @@ AbortSystemShutdownA(LPCSTR lpMachineName)
|
||||||
Status = RtlAnsiStringToUnicodeString(&MachineNameW, &MachineNameA, TRUE);
|
Status = RtlAnsiStringToUnicodeString(&MachineNameW, &MachineNameA, TRUE);
|
||||||
if (STATUS_SUCCESS != Status)
|
if (STATUS_SUCCESS != Status)
|
||||||
{
|
{
|
||||||
SetLastError(RtlNtStatusToDosError(Status));
|
SetLastError(RtlNtStatusToDosError(Status));
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
rv = AbortSystemShutdownW(MachineNameW.Buffer);
|
rv = AbortSystemShutdownW(MachineNameW.Buffer);
|
||||||
|
@ -71,7 +69,8 @@ InitiateSystemShutdownW(LPWSTR lpMachineName,
|
||||||
bRebootAfterShutdown,
|
bRebootAfterShutdown,
|
||||||
SHTDN_REASON_MAJOR_OTHER |
|
SHTDN_REASON_MAJOR_OTHER |
|
||||||
SHTDN_REASON_MINOR_OTHER |
|
SHTDN_REASON_MINOR_OTHER |
|
||||||
SHTDN_REASON_FLAG_PLANNED);
|
SHTDN_REASON_FLAG_PLANNED
|
||||||
|
/* SHTDN_REASON_MAJOR_LEGACY_API */);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
|
@ -94,7 +93,8 @@ InitiateSystemShutdownA(LPSTR lpMachineName,
|
||||||
bRebootAfterShutdown,
|
bRebootAfterShutdown,
|
||||||
SHTDN_REASON_MAJOR_OTHER |
|
SHTDN_REASON_MAJOR_OTHER |
|
||||||
SHTDN_REASON_MINOR_OTHER |
|
SHTDN_REASON_MINOR_OTHER |
|
||||||
SHTDN_REASON_FLAG_PLANNED);
|
SHTDN_REASON_FLAG_PLANNED
|
||||||
|
/* SHTDN_REASON_MAJOR_LEGACY_API */);
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
|
@ -110,23 +110,37 @@ InitiateSystemShutdownExW(LPWSTR lpMachineName,
|
||||||
BOOL bRebootAfterShutdown,
|
BOOL bRebootAfterShutdown,
|
||||||
DWORD dwReason)
|
DWORD dwReason)
|
||||||
{
|
{
|
||||||
SHUTDOWN_ACTION Action = ShutdownNoReboot;
|
SHUTDOWN_ACTION action;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
ULONG Timeout_ms;
|
||||||
|
|
||||||
if (lpMachineName)
|
/* Convert to milliseconds so we can use the value later on */
|
||||||
|
Timeout_ms = dwTimeout * 1000;
|
||||||
|
|
||||||
|
if (lpMachineName != NULL)
|
||||||
{
|
{
|
||||||
/* FIXME: remote machine shutdown not supported yet */
|
/* FIXME: Remote system shutdown not supported yet */
|
||||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
else /* The local system is being used */
|
||||||
if (dwTimeout)
|
|
||||||
{
|
{
|
||||||
|
/* FIXME: Right now, only basic shutting down and rebooting
|
||||||
|
is supported */
|
||||||
|
if(bRebootAfterShutdown == TRUE)
|
||||||
|
{
|
||||||
|
action = ShutdownReboot;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
action = ShutdownNoReboot;
|
||||||
|
}
|
||||||
|
|
||||||
|
Status = NtShutdownSystem(action);
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = NtShutdownSystem(Action);
|
|
||||||
SetLastError(RtlNtStatusToDosError(Status));
|
SetLastError(RtlNtStatusToDosError(Status));
|
||||||
return FALSE;
|
return (Status == STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
|
@ -186,6 +200,8 @@ InitiateSystemShutdownExA(LPSTR lpMachineName,
|
||||||
bRebootAfterShutdown,
|
bRebootAfterShutdown,
|
||||||
dwReason);
|
dwReason);
|
||||||
LastError = GetLastError();
|
LastError = GetLastError();
|
||||||
|
|
||||||
|
/* Clear the values of both strings */
|
||||||
if (lpMachineName)
|
if (lpMachineName)
|
||||||
RtlFreeUnicodeString(&MachineNameW);
|
RtlFreeUnicodeString(&MachineNameW);
|
||||||
|
|
||||||
|
@ -215,7 +231,7 @@ InitiateShutdownW(LPWSTR lpMachineName,
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* InitiateShutdownA [ADVAPI32.@]
|
* InitiateShutdownA [ADVAPI32.@]
|
||||||
*
|
*
|
||||||
* @unimplamented
|
* see InitiateShutdownW
|
||||||
*/
|
*/
|
||||||
DWORD WINAPI
|
DWORD WINAPI
|
||||||
InitiateShutdownA(LPSTR lpMachineName,
|
InitiateShutdownA(LPSTR lpMachineName,
|
||||||
|
@ -267,6 +283,8 @@ InitiateShutdownA(LPSTR lpMachineName,
|
||||||
dwShutdownFlags,
|
dwShutdownFlags,
|
||||||
dwReason);
|
dwReason);
|
||||||
LastError = GetLastError();
|
LastError = GetLastError();
|
||||||
|
|
||||||
|
/* Clear the values of both strings */
|
||||||
if (lpMachineName)
|
if (lpMachineName)
|
||||||
RtlFreeUnicodeString(&MachineNameW);
|
RtlFreeUnicodeString(&MachineNameW);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue