2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS logoff utility
4 * FILE: base/applications/logoff/logoff.c
5 * PURPOSE: Logoff current session, or another session, potentially on another machine
6 * AUTHOR: 30.07.2007 - Frode Lillerud
10 * This application is a lightweight version of shutdown.exe. It is intended
11 * to be function-compatible with Windows' system32\logoff.exe application.
24 /* Command-line argument switches */
25 LPWSTR szRemoteServerName
= NULL
;
28 //----------------------------------------------------------------------
30 // Writes the last error as both text and error code to the console.
32 //----------------------------------------------------------------------
33 VOID
DisplayError(DWORD dwError
)
35 ConMsgPuts(StdErr
, FORMAT_MESSAGE_FROM_SYSTEM
,
36 NULL
, dwError
, LANG_USER_DEFAULT
);
37 ConPrintf(StdErr
, L
"Error code: %lu\n", dwError
);
40 //----------------------------------------------------------------------
42 // Sets flags based on command-line arguments
44 //----------------------------------------------------------------------
45 BOOL
ParseCommandLine(int argc
, WCHAR
*argv
[])
49 // FIXME: Add handling of command-line arguments to select
50 // the session number and name, and also name of remote machine.
51 // Example: logoff.exe 4 /SERVER:Master
52 // should logoff session number 4 on remote machine called Master.
54 for (i
= 1; i
< argc
; i
++)
61 if (argv
[i
][1] == L
'v')
67 else if (argv
[i
][1] == L
'?')
69 /* Will display the Usage */
74 /* Invalid parameter detected */
75 ConResPuts(StdErr
, IDS_ILLEGAL_PARAM
);
83 //----------------------------------------------------------------------
85 // Main entry for program
87 //----------------------------------------------------------------------
88 int wmain(int argc
, WCHAR
*argv
[])
90 /* Initialize the Console Standard Streams */
93 /* Parse command line */
94 if (!ParseCommandLine(argc
, argv
))
96 ConResPuts(StdOut
, IDS_USAGE
);
100 /* Should we log off session on remote server? */
101 if (szRemoteServerName
)
104 ConResPuts(StdOut
, IDS_LOGOFF_REMOTE
);
106 // FIXME: Add Remote Procedure Call to logoff user on a remote machine
107 ConPuts(StdErr
, L
"Remote Procedure Call in logoff.exe has not been implemented");
109 /* Perform logoff of current session on local machine instead */
114 /* Get resource string and print it */
115 ConResPuts(StdOut
, IDS_LOGOFF_LOCAL
);
119 if (!ExitWindowsEx(EWX_LOGOFF
, 0))
121 DisplayError(GetLastError());