75{
83 DWORD uApiHostNameSize;
84 CHAR szApiHostName[256] =
"";
85 CHAR szHostNameOld[256] =
"";
86 CHAR szHostNameNew[256] =
"";
87 CHAR hostbuffer[256] =
"";
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105 uApiHostNameSize =
_countof(szApiHostName);
107 {
108
109 skip(
"GetComputerNameExA(ComputerNameDnsHostname) failed, error %lu\n",
GetLastError());
110 return;
111 }
112 printf(
"The Hostname from API is '%s'.\n", szApiHostName);
113
114
116 {
117
118 skip(
"Error while retrieving the host name using the 'hostname' command!\n");
119 return;
120 }
121 printf(
"The Hostname from command is '%s'.\n", hostbuffer);
122
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);
126
128 ok(hKeyHN !=
NULL,
"Error while opening hostname registry key.\n");
130 return;
131
132
134 cbData =
sizeof(szHostNameOld);
136
137 printf(
"Hostname from Registry is '%s'.\n", szHostNameOld);
138
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);
142
143
145 strcat(szHostNameNew,
"ROSHOSTNAME1");
147
150
151
152 uApiHostNameSize =
_countof(szApiHostName);
154 {
155
156 skip(
"GetComputerNameExA(ComputerNameDnsHostname) failed, error %lu\n",
GetLastError());
158 }
159 printf(
"The Hostname from API is '%s'.\n", szApiHostName);
160
161
163 {
164
165 skip(
"Error while retrieving the host name using the 'hostname' command!\n");
167 }
168 printf(
"The Hostname from command is '%s'.\n", hostbuffer);
169
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);
173
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);
177
178
180
183
184
185
186
188 ok(iResult == 0,
"Error occurred starting Winsock");
189 if (iResult != 0)
191
192
193 hnError =
gethostname(hostbuffer,
sizeof(hostbuffer));
195
196
197 if (!hnError)
198 printf(
"Winsock gethostname() is '%s'.\n", hostbuffer);
199
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);
203
204
206 strcat(szHostNameNew,
"ROSHOSTNAME1");
208
211
212
213 hnError =
gethostname(hostbuffer,
sizeof(hostbuffer));
215
216
217 if (!hnError)
218 printf(
"Winsock gethostname() is '%s'.\n", hostbuffer);
219
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);
223
224
226
229
230
231 hnError =
gethostname(hostbuffer,
sizeof(hostbuffer));
233
234
235 if (!hnError)
236 printf(
"Winsock gethostname() is '%s'.\n", hostbuffer);
237
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);
241
244 ok(iResult == 0,
"WSACleanup error occurred ending Winsock");
245
248
249 return;
250}
#define RegCloseKey(hKey)
LONG WINAPI RegSetValueExA(HKEY hKey, LPCSTR lpValueName, DWORD Reserved, DWORD dwType, CONST BYTE *lpData, DWORD cbData)
LONG WINAPI RegQueryValueExA(_In_ HKEY hkeyorg, _In_ LPCSTR name, _In_ LPDWORD reserved, _Out_opt_ LPDWORD type, _Out_opt_ LPBYTE data, _Inout_opt_ LPDWORD count)
_ACRTIMP int __cdecl strcmp(const char *, const char *)
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)
BOOL WINAPI GetComputerNameExA(COMPUTER_NAME_FORMAT, LPSTR, LPDWORD)
_In_opt_ _In_opt_ _In_ _In_ DWORD cbData
DWORD WINAPI GetLastError(void)
#define HKEY_LOCAL_MACHINE
int PASCAL FAR WSAGetLastError(void)
int PASCAL FAR WSACleanup(void)