mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 23:33:01 +00:00
[HOSTNAME]
Unicodify and add localization support. Patch by Lee Schroeder, simplified by me. CORE-7142 #resolve #comment Committed in revision r58893, thanks! [REGEDIT] "Neutralize" common resources. svn path=/trunk/; revision=58893
This commit is contained in:
parent
ec8ff3a906
commit
6cdfa4a25c
8 changed files with 93 additions and 36 deletions
|
@ -1,6 +1,6 @@
|
||||||
|
|
||||||
add_executable(hostname hostname.c hostname.rc)
|
add_executable(hostname hostname.c hostname.rc)
|
||||||
|
|
||||||
set_module_type(hostname win32cui)
|
set_module_type(hostname win32cui UNICODE)
|
||||||
add_importlibs(hostname msvcrt kernel32)
|
add_importlibs(hostname user32 msvcrt kernel32)
|
||||||
add_cd_file(TARGET hostname DESTINATION reactos/system32 FOR all)
|
add_cd_file(TARGET hostname DESTINATION reactos/system32 FOR all)
|
||||||
|
|
|
@ -23,38 +23,52 @@
|
||||||
* PROGRAMMER: Emanuele Aliberti (ea@reactos.com)
|
* PROGRAMMER: Emanuele Aliberti (ea@reactos.com)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <conio.h>
|
||||||
#include <stdlib.h>
|
|
||||||
//#include <string.h>
|
|
||||||
|
|
||||||
#include <windef.h>
|
#include <windef.h>
|
||||||
#include <winbase.h>
|
#include <winbase.h>
|
||||||
|
#include <winuser.h>
|
||||||
|
|
||||||
int main (int argc, char ** argv)
|
#include "resource.h"
|
||||||
|
|
||||||
|
int wmain(int argc, WCHAR* argv[])
|
||||||
{
|
{
|
||||||
|
WCHAR Msg[100];
|
||||||
|
|
||||||
if (1 == argc)
|
if (1 == argc)
|
||||||
{
|
{
|
||||||
TCHAR ComputerName [MAX_COMPUTERNAME_LENGTH + 1];
|
WCHAR ComputerName[MAX_COMPUTERNAME_LENGTH + 1] = L"";
|
||||||
DWORD ComputerNameSize = sizeof ComputerName / sizeof ComputerName[0];
|
DWORD ComputerNameSize = sizeof(ComputerName) / sizeof(ComputerName[0]);
|
||||||
|
|
||||||
ZeroMemory (ComputerName, sizeof ComputerName );
|
if (!GetComputerName(ComputerName, &ComputerNameSize))
|
||||||
if (GetComputerName(ComputerName, & ComputerNameSize))
|
|
||||||
{
|
{
|
||||||
printf ("%s\n", ComputerName);
|
/* Fail in case of error */
|
||||||
return EXIT_SUCCESS;
|
LoadStringW(GetModuleHandle(NULL), IDS_ERROR, Msg, 100);
|
||||||
|
_cwprintf(L"%s %lu.\n", Msg, GetLastError());
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
fprintf (stderr, "%s: Win32 error %lu.\n",
|
|
||||||
argv[0], GetLastError());
|
/* Print out the computer's name */
|
||||||
return EXIT_FAILURE;
|
_cwprintf(L"%s\n", ComputerName);
|
||||||
}else{
|
}
|
||||||
if (0 == strcmp(argv[1],"-s"))
|
else
|
||||||
{
|
{
|
||||||
fprintf(stderr,"%s: -s not supported.\n",argv[0]);
|
if ((wcsicmp(argv[1], L"-s") == 0) || (wcsicmp(argv[1], L"/s") == 0))
|
||||||
return EXIT_FAILURE;
|
{
|
||||||
}else{
|
/* The program doesn't allow the user to set the computer's name */
|
||||||
printf("Print the current host's name.\n\nhostname\n");
|
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 EXIT_SUCCESS;
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* EOF */
|
/* EOF */
|
||||||
|
|
|
@ -1,4 +1,12 @@
|
||||||
#define REACTOS_STR_FILE_DESCRIPTION "Win32 Get local host name\0"
|
#include <windef.h>
|
||||||
#define REACTOS_STR_INTERNAL_NAME "hostname\0"
|
|
||||||
#define REACTOS_STR_ORIGINAL_FILENAME "hostname.exe\0"
|
#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 <reactos/version.rc>
|
#include <reactos/version.rc>
|
||||||
|
|
||||||
|
#include "rsrc.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
|
|
@ -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
|
8
reactos/base/applications/cmdutils/hostname/resource.h
Normal file
8
reactos/base/applications/cmdutils/hostname/resource.h
Normal file
|
@ -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 */
|
11
reactos/base/applications/cmdutils/hostname/rsrc.rc
Normal file
11
reactos/base/applications/cmdutils/hostname/rsrc.rc
Normal file
|
@ -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
|
|
@ -24,12 +24,12 @@
|
||||||
|
|
||||||
#include "resource.h"
|
#include "resource.h"
|
||||||
|
|
||||||
#define REACTOS_STR_FILE_DESCRIPTION "ReactOS Registry Explorer\0"
|
#define REACTOS_STR_FILE_DESCRIPTION "ReactOS Registry Explorer"
|
||||||
#define REACTOS_STR_INTERNAL_NAME "regedit\0"
|
#define REACTOS_STR_INTERNAL_NAME "regedit"
|
||||||
#define REACTOS_STR_ORIGINAL_FILENAME "regedit.exe\0"
|
#define REACTOS_STR_ORIGINAL_FILENAME "regedit.exe"
|
||||||
#include <reactos/version.rc>
|
#include <reactos/version.rc>
|
||||||
|
|
||||||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
|
||||||
|
|
||||||
#include "rsrc.rc"
|
#include "rsrc.rc"
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue