[INTL]
[reactos.git] / reactos / base / applications / cmdutils / hostname / hostname.c
1 /*
2 * ReactOS Win32 Applications
3 * Copyright (C) 2005 ReactOS Team
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19 /*
20 * COPYRIGHT : See COPYING in the top level directory
21 * PROJECT : ReactOS/Win32 get host name
22 * FILE : subsys/system/hostname/hostname.c
23 * PROGRAMMER: Emanuele Aliberti (ea@reactos.com)
24 */
25
26 #include <conio.h>
27
28 #include <windef.h>
29 #include <winbase.h>
30 #include <winuser.h>
31
32 #include "resource.h"
33
34 int wmain(int argc, WCHAR* argv[])
35 {
36 WCHAR Msg[100];
37
38 if (1 == argc)
39 {
40 WCHAR ComputerName[MAX_COMPUTERNAME_LENGTH + 1] = L"";
41 DWORD ComputerNameSize = sizeof(ComputerName) / sizeof(ComputerName[0]);
42
43 if (!GetComputerName(ComputerName, &ComputerNameSize))
44 {
45 /* Fail in case of error */
46 LoadStringW(GetModuleHandle(NULL), IDS_ERROR, Msg, 100);
47 _cwprintf(L"%s %lu.\n", Msg, GetLastError());
48 return 1;
49 }
50
51 /* Print out the computer's name */
52 _cwprintf(L"%s\n", ComputerName);
53 }
54 else
55 {
56 if ((wcsicmp(argv[1], L"-s") == 0) || (wcsicmp(argv[1], L"/s") == 0))
57 {
58 /* The program doesn't allow the user to set the computer's name */
59 LoadStringW(GetModuleHandle(NULL), IDS_NOSET, Msg, 100);
60 _cwprintf(L"%s\n", Msg);
61 return 1;
62 }
63 else
64 {
65 /* Let the user know what the program does */
66 LoadStringW(GetModuleHandle(NULL), IDS_USAGE, Msg, 100);
67 _cwprintf(L"\n%s\n\n", Msg);
68 }
69 }
70
71 return 0;
72 }
73
74 /* EOF */