4e49c5d4182bed6a096389075124c9ce181fe66b
2 * ReactOS Win32 Applications
3 * Copyright (C) 2005 ReactOS Team
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.
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.
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.
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)
34 int wmain(int argc
, WCHAR
* argv
[])
40 WCHAR ComputerName
[MAX_COMPUTERNAME_LENGTH
+ 1] = L
"";
41 DWORD ComputerNameSize
= sizeof(ComputerName
) / sizeof(ComputerName
[0]);
43 if (!GetComputerName(ComputerName
, &ComputerNameSize
))
45 /* Fail in case of error */
46 LoadStringW(GetModuleHandle(NULL
), IDS_ERROR
, Msg
, 100);
47 _cwprintf(L
"%s %lu.\n", Msg
, GetLastError());
51 /* Print out the computer's name */
52 _cwprintf(L
"%s\n", ComputerName
);
56 if ((wcsicmp(argv
[1], L
"-s") == 0) || (wcsicmp(argv
[1], L
"/s") == 0))
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
);
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
);