active window remains active.
5 Activates the window and displays it in its current size and
position.
6 Minimizes the specified window and activates the next top-level
window in the Z order.
7 Displays the window as a minimized window. The active window
remains active.
8 Displays the window in its current state. The active window
remains active.
9 Activates and displays the window. If the window is minimized or
maximized, the system restores it to its original size and position. An
application should specify this flag when restoring a minimized window.
10 Sets the show state based on the state of the program that
started the application.
关机,支持2000,xp
[PB external function declaration]
FUNCTION boolean ExitWindowsEx(ulong uFlags, long dwReserved ) &
LIBRARY 'user32.dll'
[Powerscript]
ulong EWX_LOGOFF = 0
ulong EWX_SHUTDOWN = 1
ulong EWX_REBOOT = 2
ExitWindows(EWX_REBOOT, 0)
NOTE: While you can shutdown from an application in Win95, you can't with WinNT. You need to call first the AdjustTokenPrivileges API function to grant the current process to right to shutdown the workstation. [structure definitions]
luid
unsignedlong lowpart
long highpart
luid_and_attributes
luid pluid
long attributes
token_privileges
long privilegecount
luid_and_attributes privileges
[functions declaration]
Function long OpenProcessToken
(long ProcessHandle, long DesiredAccess, ref long TokenHandle) Library "ADVAPI32.DLL"
Function long GetCurrentProcess () Library "kernel32"
Function long LookupPrivilegevalue
(string lpSystemName, string lpName, ref LUID lpLUID)
Library "ADVAPI32.DLL" Alias for "LookupPrivilegevalueA"
Function long AdjustTokenPrivileges
(long TokenHandle, long DisableAllPrivileges, ref TOKEN_PRIVILEGES newstate, long BufferLength, ref TOKEN_PRIVILEGES PreviousState, ref long ReturnLength)
Library "ADVAPI32.DLL"
Function long CloseHandle (long hObject) Library "kernel32"
FUNCTION long ExitWindowsEx(uint Flags, long dwReserved)
LIBRARY "User32.dll"
[Powerscript]
Constant string SE_SHUTDOWN_NAME = "SeShutdownPrivilege"
Constant long SE_PRIVILEGE_ENABLED = 2
Constant long TOKEN_ADJUST_PRIVILEGES = 32
Constant long TOKEN_QUERY = 8
CONSTANT long TokenDefaultDacl = 6
CONSTANT long TokenGroups = 2
CONSTANT long TokenImpersonationLevel = 9
CONSTANT long TokenOwner = 4
CONSTANT long TokenPrimaryGroup = 5
CONSTANT long TokenPrivileges = 3
CONSTANT long TokenSource = 7
CONSTANT long TokenStatistics = 10
CONSTANT long TokenType = 8
CONSTANT long TokenUser = 1
CONSTANT INTEGER EWX_LOGOFF = 0
CONSTANT INTEGER EWX_SHUTDOW