|
| Rating: | 80% (2 votes registred) |
|
The program RunDll32.exe calls the function SHExitWindowsEx in Shell32.dll. The function requests one parameter, which must be a string defining a hexadecimal number for the exit mode. The string must be written as 0x0... The string 0x0 defines the value 0, 0x01 defines 1 and so on. SHExitWindowsEx reads this parameter, converts it to a hexadecimal value and calls the API-function ExitWindowsEx. The following table specifies the values you may use: | Command | Remark | | Shell32.dll,ExitWindowsEx,0x0 | Logoff | | Shell32.dll,ExitWindowsEx,0x1 | Shutdown | | Shell32.dll,ExitWindowsEx,0x2 | Restart |
Sample code:
Function ExitWindows(nWhatToDo) LOCAL cWhatTDoDo
DO CASE CASE nWhatToDo = 1 cWhatToDo:="0x0" // Logoff Windows CASE nWhatToDo = 2 cWhatToDo:="0x1" // Shutdown Windows CASE nWhatToDo = 3 cWhatToDo:="0x2" // Restart Windows OTHER RETURN MsgStop(Str(nWhatToDo)+" is not a valid option.") ENDCASE WinExec( "RunDll32.exe Shell32.dll,SHExitWindowsEx "+cWhatToDo ) RETURN NIL |
|