13#define REG_HOSTNAME_KEY L"System\\CurrentControlSet\\Services\\Tcpip\\Parameters"
14#define REG_COMPUTERNAME_KEY L"System\\CurrentControlSet\\Control\\ComputerName\\ComputerName"
49 ok(fp !=
NULL,
"An error occurred while opening the file.\n");
54 ptr =
fgets(pszHostnameBuffer, ulBufferSize *
sizeof(
CHAR), fp);
55 ok(
ptr !=
NULL,
"An error occurred while reading the file.\n");
61 if (pszHostnameBuffer[
len-1] ==
'\r' || pszHostnameBuffer[
len-1] ==
'\n')
67 ok(iResult == 0,
"An error occurred while closing the file: %i.\n", iResult);
69 ok(iResult == 0,
"An error occurred while deleting the file: %i.\n", iResult);
83 DWORD uApiHostNameSize;
84 CHAR szApiHostName[256] =
"";
85 CHAR szHostNameOld[256] =
"";
86 CHAR szHostNameNew[256] =
"";
87 CHAR hostbuffer[256] =
"";
105 uApiHostNameSize =
_countof(szApiHostName);
109 skip(
"GetComputerNameExA(ComputerNameDnsHostname) failed, error %lu\n",
GetLastError());
112 printf(
"The Hostname from API is '%s'.\n", szApiHostName);
118 skip(
"Error while retrieving the host name using the 'hostname' command!\n");
121 printf(
"The Hostname from command is '%s'.\n", hostbuffer);
124 printf(
"The test results were '%s'.\n",
pos==0 ?
"good" :
"bad");
125 ok(
pos == 0,
"hostbuffer '%s' should have been szApiHostName '%s'.\n", hostbuffer, szApiHostName);
128 ok(hKeyHN !=
NULL,
"Error while opening hostname registry key.\n");
134 cbData =
sizeof(szHostNameOld);
137 printf(
"Hostname from Registry is '%s'.\n", szHostNameOld);
139 pos =
strcmp(szHostNameOld, szApiHostName);
140 printf(
"The test results were '%s'.\n",
pos==0 ?
"good" :
"bad");
141 ok(
pos == 0,
"szApiHostName '%s' should have been szHostNameOld '%s'.\n", szApiHostName, szHostNameOld);
145 strcat(szHostNameNew,
"ROSHOSTNAME1");
146 cbData =
lstrlenA(szHostNameNew) + 1;
152 uApiHostNameSize =
_countof(szApiHostName);
156 skip(
"GetComputerNameExA(ComputerNameDnsHostname) failed, error %lu\n",
GetLastError());
159 printf(
"The Hostname from API is '%s'.\n", szApiHostName);
165 skip(
"Error while retrieving the host name using the 'hostname' command!\n");
168 printf(
"The Hostname from command is '%s'.\n", hostbuffer);
170 pos =
strcmp(szHostNameNew, szApiHostName);
171 printf(
"The test results were '%s'.\n",
pos==0 ?
"good" :
"bad");
172 ok(
pos == 0,
"szApiHostName '%s' should be szHostNameNew '%s'.\n", szApiHostName, szHostNameNew);
175 printf(
"The test results were '%s'.\n",
pos==0 ?
"good" :
"bad");
176 ok(
pos == 0,
"hostbuffer '%s' should have been szHostNameNew '%s'.\n", hostbuffer, szHostNameNew);
179 cbData =
lstrlenA(szHostNameOld) + 1;
188 ok(iResult == 0,
"Error occurred starting Winsock");
193 hnError =
gethostname(hostbuffer,
sizeof(hostbuffer));
198 printf(
"Winsock gethostname() is '%s'.\n", hostbuffer);
201 printf(
"The test results were '%s'.\n",
pos==0 ?
"good" :
"bad");
202 ok(
pos == 0,
"szHostNameOld '%s' should be hostbuffer '%s'.\n", szHostNameOld, hostbuffer);
206 strcat(szHostNameNew,
"ROSHOSTNAME1");
207 cbData =
lstrlenA(szHostNameNew) + 1;
213 hnError =
gethostname(hostbuffer,
sizeof(hostbuffer));
218 printf(
"Winsock gethostname() is '%s'.\n", hostbuffer);
221 printf(
"The test results were '%s'.\n",
pos==0 ?
"good" :
"bad");
222 ok(
pos == 0,
"szHostNameNew '%s' should be hostbuffer '%s'.\n", szHostNameNew, hostbuffer);
225 cbData =
lstrlenA(szHostNameOld) + 1;
231 hnError =
gethostname(hostbuffer,
sizeof(hostbuffer));
236 printf(
"Winsock gethostname() is '%s'.\n", hostbuffer);
239 printf(
"The test results were '%s'.\n",
pos==0 ?
"good" :
"bad");
240 ok(
pos == 0,
"szHostNameOld '%s' should be hostbuffer '%s'.\n", szHostNameOld, hostbuffer);
244 ok(iResult == 0,
"WSACleanup error occurred ending Winsock");
char * strcat(char *DstString, const char *SrcString)
int strcmp(const char *String1, const char *String2)
#define RegCloseKey(hKey)
LONG WINAPI RegSetValueExA(HKEY hKey, LPCSTR lpValueName, DWORD Reserved, DWORD dwType, CONST BYTE *lpData, DWORD cbData)
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
LONG WINAPI RegQueryValueExA(_In_ HKEY hkeyorg, _In_ LPCSTR name, _In_ LPDWORD reserved, _Out_opt_ LPDWORD type, _Out_opt_ LPBYTE data, _Inout_opt_ LPDWORD count)
static const WCHAR Cleanup[]
INT WINAPI WSAStartup(IN WORD wVersionRequested, OUT LPWSADATA lpWSAData)
BOOL GetHostnameFromCommand(OUT PSTR pszHostnameBuffer, IN ULONG ulBufferSize)
HKEY OpenRegKey(IN HKEY hRootKey, IN PCWSTR pszSubKey, IN DWORD ulOptions)
INT WSAAPI gethostname(OUT char FAR *name, IN INT namelen)
_Check_return_ _CRTIMP FILE *__cdecl fopen(_In_z_ const char *_Filename, _In_z_ const char *_Mode)
_Check_return_opt_ _CRTIMP char *__cdecl fgets(_Out_writes_z_(_MaxCount) char *_Buf, _In_ int _MaxCount, _Inout_ FILE *_File)
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)
BOOL WINAPI GetComputerNameExA(COMPUTER_NAME_FORMAT, LPSTR, LPDWORD)
int WINAPI lstrlenA(LPCSTR lpString)
int __cdecl system(_In_opt_z_ const char *_Command)
DWORD WINAPI GetLastError(void)
#define HKEY_LOCAL_MACHINE
int PASCAL FAR WSAGetLastError(void)
int PASCAL FAR WSACleanup(void)