ReactOS  0.4.12-dev-102-g4b7f1e0
hostname.c File Reference
#include <conio.h>
#include <windef.h>
#include <winbase.h>
#include <winuser.h>
#include "resource.h"
Include dependency graph for hostname.c:

Go to the source code of this file.

Functions

int wmain (int argc, WCHAR *argv[])
 

Function Documentation

◆ wmain()

int wmain ( int  argc,
WCHAR argv[] 
)

Definition at line 34 of file hostname.c.

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 */
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 */
60  _cwprintf(L"%s\n", Msg);
61  return 1;
62  }
63  else
64  {
65  /* Let the user know what the program does */
67  _cwprintf(L"\n%s\n\n", Msg);
68  }
69  }
70 
71  return 0;
72 }
static int argc
Definition: ServiceArgs.c:12
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define GetComputerName
Definition: winbase.h:3614
int __cdecl _cwprintf(const MSVCRT_wchar_t *,...)
Definition: _cwprintf.c:14
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define IDS_USAGE
Definition: resource.h:3
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
static char ** argv
Definition: ServiceArgs.c:11
struct @1571 Msg[]
smooth NULL
Definition: ftsmooth.c:416
#define IDS_NOSET
Definition: resource.h:4
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1087
#define wcsicmp
Definition: string.h:1152
#define MAX_COMPUTERNAME_LENGTH
Definition: winbase.h:240
#define GetModuleHandle
Definition: winbase.h:3641
#define IDS_ERROR
Definition: resource.h:18