diff --git a/reactos/base/applications/cmdutils/hostname/CMakeLists.txt b/reactos/base/applications/cmdutils/hostname/CMakeLists.txt index d9e9edac79f..fec5032e916 100644 --- a/reactos/base/applications/cmdutils/hostname/CMakeLists.txt +++ b/reactos/base/applications/cmdutils/hostname/CMakeLists.txt @@ -1,6 +1,6 @@ add_executable(hostname hostname.c hostname.rc) -set_module_type(hostname win32cui) -add_importlibs(hostname msvcrt kernel32) +set_module_type(hostname win32cui UNICODE) +add_importlibs(hostname user32 msvcrt kernel32) add_cd_file(TARGET hostname DESTINATION reactos/system32 FOR all) diff --git a/reactos/base/applications/cmdutils/hostname/hostname.c b/reactos/base/applications/cmdutils/hostname/hostname.c index 759015f5d94..4e49c5d4182 100644 --- a/reactos/base/applications/cmdutils/hostname/hostname.c +++ b/reactos/base/applications/cmdutils/hostname/hostname.c @@ -23,38 +23,52 @@ * PROGRAMMER: Emanuele Aliberti (ea@reactos.com) */ -#include -#include -//#include +#include #include #include +#include -int main (int argc, char ** argv) +#include "resource.h" + +int wmain(int argc, WCHAR* argv[]) { - if (1 == argc) - { - TCHAR ComputerName [MAX_COMPUTERNAME_LENGTH + 1]; - DWORD ComputerNameSize = sizeof ComputerName / sizeof ComputerName[0]; + WCHAR Msg[100]; - ZeroMemory (ComputerName, sizeof ComputerName ); - if (GetComputerName(ComputerName, & ComputerNameSize)) - { - printf ("%s\n", ComputerName); - return EXIT_SUCCESS; - } - fprintf (stderr, "%s: Win32 error %lu.\n", - argv[0], GetLastError()); - return EXIT_FAILURE; - }else{ - if (0 == strcmp(argv[1],"-s")) - { - fprintf(stderr,"%s: -s not supported.\n",argv[0]); - return EXIT_FAILURE; - }else{ - printf("Print the current host's name.\n\nhostname\n"); - } - } - return EXIT_SUCCESS; + if (1 == argc) + { + WCHAR ComputerName[MAX_COMPUTERNAME_LENGTH + 1] = L""; + DWORD ComputerNameSize = sizeof(ComputerName) / sizeof(ComputerName[0]); + + if (!GetComputerName(ComputerName, &ComputerNameSize)) + { + /* Fail in case of error */ + LoadStringW(GetModuleHandle(NULL), IDS_ERROR, Msg, 100); + _cwprintf(L"%s %lu.\n", Msg, GetLastError()); + return 1; + } + + /* Print out the computer's name */ + _cwprintf(L"%s\n", ComputerName); + } + else + { + if ((wcsicmp(argv[1], L"-s") == 0) || (wcsicmp(argv[1], L"/s") == 0)) + { + /* The program doesn't allow the user to set the computer's name */ + LoadStringW(GetModuleHandle(NULL), IDS_NOSET, Msg, 100); + _cwprintf(L"%s\n", Msg); + return 1; + } + else + { + /* Let the user know what the program does */ + LoadStringW(GetModuleHandle(NULL), IDS_USAGE, Msg, 100); + _cwprintf(L"\n%s\n\n", Msg); + } + } + + return 0; } + /* EOF */ diff --git a/reactos/base/applications/cmdutils/hostname/hostname.rc b/reactos/base/applications/cmdutils/hostname/hostname.rc index 227ff6a10fe..368c0b8f58e 100644 --- a/reactos/base/applications/cmdutils/hostname/hostname.rc +++ b/reactos/base/applications/cmdutils/hostname/hostname.rc @@ -1,4 +1,12 @@ -#define REACTOS_STR_FILE_DESCRIPTION "Win32 Get local host name\0" -#define REACTOS_STR_INTERNAL_NAME "hostname\0" -#define REACTOS_STR_ORIGINAL_FILENAME "hostname.exe\0" +#include + +#include "resource.h" + +LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL + +#define REACTOS_STR_FILE_DESCRIPTION "Host name application" +#define REACTOS_STR_INTERNAL_NAME "hostname" +#define REACTOS_STR_ORIGINAL_FILENAME "hostname.exe" #include + +#include "rsrc.rc" diff --git a/reactos/base/applications/cmdutils/hostname/lang/en-US.rc b/reactos/base/applications/cmdutils/hostname/lang/en-US.rc new file mode 100644 index 00000000000..84bc606fa21 --- /dev/null +++ b/reactos/base/applications/cmdutils/hostname/lang/en-US.rc @@ -0,0 +1,8 @@ +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US + +STRINGTABLE DISCARDABLE +BEGIN + IDS_USAGE, "Print the current host's name.\n\nhostname" + IDS_NOSET, "hostname -s is not supported." + IDS_ERROR, "Win32 error" +END diff --git a/reactos/base/applications/cmdutils/hostname/lang/fr-FR.rc b/reactos/base/applications/cmdutils/hostname/lang/fr-FR.rc new file mode 100644 index 00000000000..751ae691633 --- /dev/null +++ b/reactos/base/applications/cmdutils/hostname/lang/fr-FR.rc @@ -0,0 +1,8 @@ +LANGUAGE LANG_FRENCH, SUBLANG_NEUTRAL + +STRINGTABLE DISCARDABLE +BEGIN + IDS_USAGE, "Affiche le nom de l'hôte actuel.\n\nhostname" + IDS_NOSET, "hostname -s n'est pas pris en charge." + IDS_ERROR, "Erreur Win32" +END diff --git a/reactos/base/applications/cmdutils/hostname/resource.h b/reactos/base/applications/cmdutils/hostname/resource.h new file mode 100644 index 00000000000..1a17b7b8a2c --- /dev/null +++ b/reactos/base/applications/cmdutils/hostname/resource.h @@ -0,0 +1,8 @@ +#ifndef RESOURCE_H +#define RESOURCE_H + +#define IDS_USAGE 0 +#define IDS_NOSET 1 +#define IDS_ERROR 2 + +#endif /* RESOURCE_H */ diff --git a/reactos/base/applications/cmdutils/hostname/rsrc.rc b/reactos/base/applications/cmdutils/hostname/rsrc.rc new file mode 100644 index 00000000000..5177a1c5183 --- /dev/null +++ b/reactos/base/applications/cmdutils/hostname/rsrc.rc @@ -0,0 +1,11 @@ +LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL + +// UTF-8 +#pragma code_page(65001) + +#ifdef LANGUAGE_EN_US + #include "lang/en-US.rc" +#endif +#ifdef LANGUAGE_FR_FR + #include "lang/fr-FR.rc" +#endif diff --git a/reactos/base/applications/regedit/regedit.rc b/reactos/base/applications/regedit/regedit.rc index 456ff4d1759..d25727bf783 100644 --- a/reactos/base/applications/regedit/regedit.rc +++ b/reactos/base/applications/regedit/regedit.rc @@ -24,12 +24,12 @@ #include "resource.h" -#define REACTOS_STR_FILE_DESCRIPTION "ReactOS Registry Explorer\0" -#define REACTOS_STR_INTERNAL_NAME "regedit\0" -#define REACTOS_STR_ORIGINAL_FILENAME "regedit.exe\0" +#define REACTOS_STR_FILE_DESCRIPTION "ReactOS Registry Explorer" +#define REACTOS_STR_INTERNAL_NAME "regedit" +#define REACTOS_STR_ORIGINAL_FILENAME "regedit.exe" #include -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL #include "rsrc.rc"