2 * Unit test suite for environment functions.
4 * Copyright 2002 Dmitry Timoshkov
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 #include "wine/test.h"
29 static CHAR string[MAX_PATH];
30 #define ok_w(res, format, szString) \
32 WideCharToMultiByte(CP_ACP, 0, szString, -1, string, MAX_PATH, NULL, NULL); \
33 ok(res, format, string);
35 static BOOL (WINAPI *pGetComputerNameExA)(COMPUTER_NAME_FORMAT,LPSTR,LPDWORD);
36 static BOOL (WINAPI *pGetComputerNameExW)(COMPUTER_NAME_FORMAT,LPWSTR,LPDWORD);
37 static BOOL (WINAPI *pOpenProcessToken)(HANDLE,DWORD,PHANDLE);
38 static BOOL (WINAPI *pGetUserProfileDirectoryA)(HANDLE,LPSTR,LPDWORD);
40 static void init_functionpointers(void)
42 HMODULE hkernel32 = GetModuleHandleA("kernel32.dll");
43 HMODULE hadvapi32 = GetModuleHandleA("advapi32.dll");
44 HMODULE huserenv = LoadLibraryA("userenv.dll");
46 pGetComputerNameExA = (void *)GetProcAddress(hkernel32, "GetComputerNameExA");
47 pGetComputerNameExW = (void *)GetProcAddress(hkernel32, "GetComputerNameExW");
48 pOpenProcessToken = (void *)GetProcAddress(hadvapi32, "OpenProcessToken");
49 pGetUserProfileDirectoryA = (void *)GetProcAddress(huserenv,
50 "GetUserProfileDirectoryA");
53 static void test_Predefined(void)
57 char Env[sizeof(Data)];
63 * Check value of %USERPROFILE%, should be same as GetUserProfileDirectory()
64 * If this fails, your test environment is probably not set up
66 if (pOpenProcessToken == NULL || pGetUserProfileDirectoryA == NULL)
68 skip("Skipping USERPROFILE check\n");
71 NoErr = pOpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &Token);
72 ok(NoErr, "Failed to open token, error %u\n", GetLastError());
73 DataSize = sizeof(Data);
74 NoErr = pGetUserProfileDirectoryA(Token, Data, &DataSize);
75 todo_wine ok(NoErr, "Failed to get user profile dir, error %u\n",
79 EnvSize = GetEnvironmentVariableA("USERPROFILE", Env, sizeof(Env));
80 ok(EnvSize != 0 && EnvSize <= sizeof(Env),
81 "Failed to retrieve environment variable USERPROFILE, error %u\n",
83 ok(strcmp(Data, Env) == 0,
84 "USERPROFILE env var %s doesn't match GetUserProfileDirectory %s\n",
88 skip("Skipping USERPROFILE check, can't get user profile dir\n");
89 NoErr = CloseHandle(Token);
90 ok(NoErr, "Failed to close token, error %u\n", GetLastError());
93 static void test_GetSetEnvironmentVariableA(void)
98 static const char name[] = "SomeWildName";
99 static const char name_cased[] = "sOMEwILDnAME";
100 static const char value[] = "SomeWildValue";
102 ret = SetEnvironmentVariableA(name, value);
104 "unexpected error in SetEnvironmentVariableA, GetLastError=%d\n",
107 /* Try to retrieve the environment variable we just set */
108 ret_size = GetEnvironmentVariableA(name, NULL, 0);
109 ok(ret_size == strlen(value) + 1,
110 "should return length with terminating 0 ret_size=%d\n", ret_size);
112 lstrcpyA(buf, "foo");
113 ret_size = GetEnvironmentVariableA(name, buf, lstrlenA(value));
114 ok(lstrcmpA(buf, "foo") == 0, "should not touch the buffer\n");
115 ok(ret_size == strlen(value) + 1,
116 "should return length with terminating 0 ret_size=%d\n", ret_size);
118 lstrcpyA(buf, "foo");
119 ret_size = GetEnvironmentVariableA(name, buf, lstrlenA(value) + 1);
120 ok(lstrcmpA(buf, value) == 0, "should touch the buffer\n");
121 ok(ret_size == strlen(value),
122 "should return length without terminating 0 ret_size=%d\n", ret_size);
124 lstrcpyA(buf, "foo");
125 ret_size = GetEnvironmentVariableA(name_cased, buf, lstrlenA(value) + 1);
126 ok(lstrcmpA(buf, value) == 0, "should touch the buffer\n");
127 ok(ret_size == strlen(value),
128 "should return length without terminating 0 ret_size=%d\n", ret_size);
130 /* Remove that environment variable */
131 ret = SetEnvironmentVariableA(name_cased, NULL);
132 ok(ret == TRUE, "should erase existing variable\n");
134 lstrcpyA(buf, "foo");
135 ret_size = GetEnvironmentVariableA(name, buf, lstrlenA(value) + 1);
136 ok(lstrcmpA(buf, "foo") == 0, "should not touch the buffer\n");
137 ok(ret_size == 0 && GetLastError() == ERROR_ENVVAR_NOT_FOUND,
138 "should not find variable but ret_size=%d GetLastError=%d\n",
139 ret_size, GetLastError());
141 /* Check behavior of SetEnvironmentVariableA(name, "") */
142 ret = SetEnvironmentVariableA(name, value);
144 "unexpected error in SetEnvironmentVariableA, GetLastError=%d\n",
147 lstrcpyA(buf, "foo");
148 ret_size = GetEnvironmentVariableA(name_cased, buf, lstrlenA(value) + 1);
149 ok(lstrcmpA(buf, value) == 0, "should touch the buffer\n");
150 ok(ret_size == strlen(value),
151 "should return length without terminating 0 ret_size=%d\n", ret_size);
153 ret = SetEnvironmentVariableA(name_cased, "");
155 "should not fail with empty value but GetLastError=%d\n", GetLastError());
157 lstrcpyA(buf, "foo");
159 ret_size = GetEnvironmentVariableA(name, buf, lstrlenA(value) + 1);
161 ((GetLastError() == 0 && lstrcmpA(buf, "") == 0) ||
162 (GetLastError() == ERROR_ENVVAR_NOT_FOUND)),
163 "%s should be set to \"\" (NT) or removed (Win9x) but ret_size=%d GetLastError=%d and buf=%s\n",
164 name, ret_size, GetLastError(), buf);
166 /* Test the limits */
167 ret_size = GetEnvironmentVariableA(NULL, NULL, 0);
168 ok(ret_size == 0 && (GetLastError() == ERROR_INVALID_PARAMETER || GetLastError() == ERROR_ENVVAR_NOT_FOUND),
169 "should not find variable but ret_size=%d GetLastError=%d\n",
170 ret_size, GetLastError());
172 ret_size = GetEnvironmentVariableA(NULL, buf, lstrlenA(value) + 1);
173 ok(ret_size == 0 && (GetLastError() == ERROR_INVALID_PARAMETER || GetLastError() == ERROR_ENVVAR_NOT_FOUND),
174 "should not find variable but ret_size=%d GetLastError=%d\n",
175 ret_size, GetLastError());
177 ret_size = GetEnvironmentVariableA("", buf, lstrlenA(value) + 1);
178 ok(ret_size == 0 && GetLastError() == ERROR_ENVVAR_NOT_FOUND,
179 "should not find variable but ret_size=%d GetLastError=%d\n",
180 ret_size, GetLastError());
183 static void test_GetSetEnvironmentVariableW(void)
188 static const WCHAR name[] = {'S','o','m','e','W','i','l','d','N','a','m','e',0};
189 static const WCHAR value[] = {'S','o','m','e','W','i','l','d','V','a','l','u','e',0};
190 static const WCHAR name_cased[] = {'s','O','M','E','w','I','L','D','n','A','M','E',0};
191 static const WCHAR empty_strW[] = { 0 };
192 static const WCHAR fooW[] = {'f','o','o',0};
194 ret = SetEnvironmentVariableW(name, value);
195 if (ret == FALSE && GetLastError()==ERROR_CALL_NOT_IMPLEMENTED)
197 /* Must be Win9x which doesn't support the Unicode functions */
198 win_skip("SetEnvironmentVariableW is not implemented\n");
202 "unexpected error in SetEnvironmentVariableW, GetLastError=%d\n",
205 /* Try to retrieve the environment variable we just set */
206 ret_size = GetEnvironmentVariableW(name, NULL, 0);
207 ok(ret_size == lstrlenW(value) + 1,
208 "should return length with terminating 0 ret_size=%d\n",
212 ret_size = GetEnvironmentVariableW(name, buf, lstrlenW(value));
213 ok_w(lstrcmpW(buf, fooW) == 0 ||
214 lstrlenW(buf) == 0, /* Vista */
215 "Expected untouched or empty buffer, got \"%s\"\n", buf);
217 ok(ret_size == lstrlenW(value) + 1,
218 "should return length with terminating 0 ret_size=%d\n", ret_size);
221 ret_size = GetEnvironmentVariableW(name, buf, lstrlenW(value) + 1);
222 ok(lstrcmpW(buf, value) == 0, "should touch the buffer\n");
223 ok(ret_size == lstrlenW(value),
224 "should return length without terminating 0 ret_size=%d\n", ret_size);
227 ret_size = GetEnvironmentVariableW(name_cased, buf, lstrlenW(value) + 1);
228 ok(lstrcmpW(buf, value) == 0, "should touch the buffer\n");
229 ok(ret_size == lstrlenW(value),
230 "should return length without terminating 0 ret_size=%d\n", ret_size);
232 /* Remove that environment variable */
233 ret = SetEnvironmentVariableW(name_cased, NULL);
234 ok(ret == TRUE, "should erase existing variable\n");
237 ret_size = GetEnvironmentVariableW(name, buf, lstrlenW(value) + 1);
238 ok(lstrcmpW(buf, fooW) == 0, "should not touch the buffer\n");
239 ok(ret_size == 0 && GetLastError() == ERROR_ENVVAR_NOT_FOUND,
240 "should not find variable but ret_size=%d GetLastError=%d\n",
241 ret_size, GetLastError());
243 /* Check behavior of SetEnvironmentVariableW(name, "") */
244 ret = SetEnvironmentVariableW(name, value);
246 "unexpected error in SetEnvironmentVariableW, GetLastError=%d\n",
250 ret_size = GetEnvironmentVariableW(name, buf, lstrlenW(value) + 1);
251 ok(lstrcmpW(buf, value) == 0, "should touch the buffer\n");
252 ok(ret_size == lstrlenW(value),
253 "should return length without terminating 0 ret_size=%d\n", ret_size);
255 ret = SetEnvironmentVariableW(name_cased, empty_strW);
256 ok(ret == TRUE, "should not fail with empty value but GetLastError=%d\n", GetLastError());
259 ret_size = GetEnvironmentVariableW(name, buf, lstrlenW(value) + 1);
260 ok(ret_size == 0 && GetLastError() == ERROR_ENVVAR_NOT_FOUND,
261 "should not find variable but ret_size=%d GetLastError=%d\n",
262 ret_size, GetLastError());
263 ok(lstrcmpW(buf, empty_strW) == 0, "should copy an empty string\n");
265 /* Test the limits */
266 ret_size = GetEnvironmentVariableW(NULL, NULL, 0);
267 ok(ret_size == 0 && GetLastError() == ERROR_ENVVAR_NOT_FOUND,
268 "should not find variable but ret_size=%d GetLastError=%d\n",
269 ret_size, GetLastError());
271 if (0) /* Both tests crash on Vista */
273 ret_size = GetEnvironmentVariableW(NULL, buf, lstrlenW(value) + 1);
274 ok(ret_size == 0 && GetLastError() == ERROR_ENVVAR_NOT_FOUND,
275 "should not find variable but ret_size=%d GetLastError=%d\n",
276 ret_size, GetLastError());
278 ret = SetEnvironmentVariableW(NULL, NULL);
279 ok(ret == FALSE && (GetLastError() == ERROR_INVALID_PARAMETER || GetLastError() == ERROR_ENVVAR_NOT_FOUND),
280 "should fail with NULL, NULL but ret=%d and GetLastError=%d\n",
281 ret, GetLastError());
285 static void test_ExpandEnvironmentStringsA(void)
287 const char* value="Long long value";
288 const char* not_an_env_var="%NotAnEnvVar%";
289 char buf[256], buf1[256], buf2[0x8000];
290 DWORD ret_size, ret_size1;
292 SetEnvironmentVariableA("EnvVar", value);
294 ret_size = ExpandEnvironmentStringsA(NULL, buf1, sizeof(buf1));
295 ok(ret_size == 1 || ret_size == 0 /* Win9x */ || ret_size == 2 /* NT4 */,
296 "ExpandEnvironmentStrings returned %d\n", ret_size);
298 /* Try to get the required buffer size 'the natural way' */
299 strcpy(buf, "%EnvVar%");
300 ret_size = ExpandEnvironmentStringsA(buf, NULL, 0);
301 ok(ret_size == strlen(value)+1 || /* win98 */
302 ret_size == (strlen(value)+1)*2 || /* NT4 */
303 ret_size == strlen(value)+2 || /* win2k, XP, win2k3 */
304 ret_size == 0 /* Win95 */,
305 "ExpandEnvironmentStrings returned %d instead of %d, %d or %d\n",
306 ret_size, lstrlenA(value)+1, lstrlenA(value)+2, 0);
308 /* Again, side-stepping the Win95 bug */
309 ret_size = ExpandEnvironmentStringsA(buf, buf1, 0);
310 /* v5.1.2600.2945 (XP SP2) returns len + 2 here! */
311 ok(ret_size == strlen(value)+1 || ret_size == strlen(value)+2 ||
312 ret_size == (strlen(value)+1)*2 /* NT4 */,
313 "ExpandEnvironmentStrings returned %d instead of %d\n",
314 ret_size, lstrlenA(value)+1);
316 /* Try with a buffer that's too small */
317 ret_size = ExpandEnvironmentStringsA(buf, buf1, 12);
318 /* v5.1.2600.2945 (XP SP2) returns len + 2 here! */
319 ok(ret_size == strlen(value)+1 || ret_size == strlen(value)+2 ||
320 ret_size == (strlen(value)+1)*2 /* NT4 */,
321 "ExpandEnvironmentStrings returned %d instead of %d\n",
322 ret_size, lstrlenA(value)+1);
324 /* Try with a buffer of just the right size */
325 /* v5.1.2600.2945 (XP SP2) needs and returns len + 2 here! */
326 ret_size = ExpandEnvironmentStringsA(buf, buf1, ret_size);
327 ok(ret_size == strlen(value)+1 || ret_size == strlen(value)+2 ||
328 ret_size == (strlen(value)+1)*2 /* NT4 */,
329 "ExpandEnvironmentStrings returned %d instead of %d\n",
330 ret_size, lstrlenA(value)+1);
331 ok(!strcmp(buf1, value), "ExpandEnvironmentStrings returned [%s]\n", buf1);
333 /* Try with an unset environment variable */
334 strcpy(buf, not_an_env_var);
335 ret_size = ExpandEnvironmentStringsA(buf, buf1, sizeof(buf1));
336 ok(ret_size == strlen(not_an_env_var)+1 ||
337 ret_size == (strlen(not_an_env_var)+1)*2 /* NT4 */,
338 "ExpandEnvironmentStrings returned %d instead of %d\n", ret_size, lstrlenA(not_an_env_var)+1);
339 ok(!strcmp(buf1, not_an_env_var), "ExpandEnvironmentStrings returned [%s]\n", buf1);
341 /* test a large destination size */
342 strcpy(buf, "12345");
343 ret_size = ExpandEnvironmentStringsA(buf, buf2, sizeof(buf2));
344 ok(!strcmp(buf, buf2), "ExpandEnvironmentStrings failed %s vs %s. ret_size = %d\n", buf, buf2, ret_size);
346 ret_size1 = GetWindowsDirectoryA(buf1,256);
347 ok ((ret_size1 >0) && (ret_size1<256), "GetWindowsDirectory Failed\n");
348 ret_size = ExpandEnvironmentStringsA("%SystemRoot%",buf,sizeof(buf));
349 if (ERROR_ENVVAR_NOT_FOUND != GetLastError())
351 ok(!strcmp(buf, buf1), "ExpandEnvironmentStrings failed %s vs %s. ret_size = %d\n", buf, buf1, ret_size);
354 /* Try with a variable that references another */
355 SetEnvironmentVariableA("IndirectVar", "Foo%EnvVar%Bar");
356 strcpy(buf, "Indirect-%IndirectVar%-Indirect");
357 strcpy(buf2, "Indirect-Foo%EnvVar%Bar-Indirect");
358 ret_size = ExpandEnvironmentStringsA(buf, buf1, sizeof(buf1));
359 ok(ret_size == strlen(buf2)+1 ||
360 ret_size == (strlen(buf2)+1)*2 /* NT4 */,
361 "ExpandEnvironmentStrings returned %d instead of %d\n", ret_size, lstrlen(buf2)+1);
362 ok(!strcmp(buf1, buf2), "ExpandEnvironmentStrings returned [%s]\n", buf1);
363 SetEnvironmentVariableA("IndirectVar", NULL);
365 SetEnvironmentVariableA("EnvVar", NULL);
368 static void test_GetComputerName(void)
378 ret = GetComputerNameA((LPSTR)0xdeadbeef, &size);
379 error = GetLastError();
380 ok(!ret && error == ERROR_BUFFER_OVERFLOW, "GetComputerNameA should have failed with ERROR_BUFFER_OVERFLOW instead of %d\n", error);
382 /* Only Vista returns the computer name length as documented in the MSDN */
385 size++; /* nul terminating character */
386 name = HeapAlloc(GetProcessHeap(), 0, size * sizeof(name[0]));
387 ok(name != NULL, "HeapAlloc failed with error %d\n", GetLastError());
388 ret = GetComputerNameA(name, &size);
389 ok(ret, "GetComputerNameA failed with error %d\n", GetLastError());
390 HeapFree(GetProcessHeap(), 0, name);
393 size = MAX_COMPUTERNAME_LENGTH + 1;
394 name = HeapAlloc(GetProcessHeap(), 0, size * sizeof(name[0]));
395 ok(name != NULL, "HeapAlloc failed with error %d\n", GetLastError());
396 ret = GetComputerNameA(name, &size);
397 ok(ret, "GetComputerNameA failed with error %d\n", GetLastError());
398 trace("computer name is \"%s\"\n", name);
399 name_len = strlen(name);
400 ok(size == name_len, "size should be same as length, name_len=%d, size=%d\n", name_len, size);
401 HeapFree(GetProcessHeap(), 0, name);
404 SetLastError(0xdeadbeef);
405 ret = GetComputerNameW((LPWSTR)0xdeadbeef, &size);
406 error = GetLastError();
407 if (error == ERROR_CALL_NOT_IMPLEMENTED)
408 win_skip("GetComputerNameW is not implemented\n");
411 ok(!ret && error == ERROR_BUFFER_OVERFLOW, "GetComputerNameW should have failed with ERROR_BUFFER_OVERFLOW instead of %d\n", error);
412 size++; /* nul terminating character */
413 nameW = HeapAlloc(GetProcessHeap(), 0, size * sizeof(nameW[0]));
414 ok(nameW != NULL, "HeapAlloc failed with error %d\n", GetLastError());
415 ret = GetComputerNameW(nameW, &size);
416 ok(ret, "GetComputerNameW failed with error %d\n", GetLastError());
417 HeapFree(GetProcessHeap(), 0, nameW);
421 static void test_GetComputerNameExA(void)
428 static const int MAX_COMP_NAME = 32767;
430 if (!pGetComputerNameExA)
432 win_skip("GetComputerNameExA function not implemented\n");
437 ret = pGetComputerNameExA(ComputerNameDnsDomain, (LPSTR)0xdeadbeef, &size);
438 error = GetLastError();
439 ok(ret == 0, "Expected 0, got %d\n", ret);
440 ok(error == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", error);
442 /* size is not set in win2k */
445 win_skip("Win2k doesn't set the size\n");
446 size = MAX_COMP_NAME;
448 name = HeapAlloc(GetProcessHeap(), 0, size * sizeof(name[0]));
449 ok(name != NULL, "HeapAlloc failed with error %d\n", GetLastError());
450 ret = pGetComputerNameExA(ComputerNameDnsDomain, name, &size);
451 ok(ret, "GetComputerNameExA(ComputerNameDnsDomain) failed with error %d\n", GetLastError());
452 trace("domain name is \"%s\"\n", name);
453 HeapFree(GetProcessHeap(), 0, name);
456 ret = pGetComputerNameExA(ComputerNameDnsFullyQualified, (LPSTR)0xdeadbeef, &size);
457 error = GetLastError();
458 ok(ret == 0, "Expected 0, got %d\n", ret);
459 ok(error == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", error);
461 /* size is not set in win2k */
463 size = MAX_COMP_NAME;
464 name = HeapAlloc(GetProcessHeap(), 0, size * sizeof(name[0]));
465 ok(name != NULL, "HeapAlloc failed with error %d\n", GetLastError());
466 ret = pGetComputerNameExA(ComputerNameDnsFullyQualified, name, &size);
467 ok(ret, "GetComputerNameExA(ComputerNameDnsFullyQualified) failed with error %d\n", GetLastError());
468 trace("fully qualified hostname is \"%s\"\n", name);
469 HeapFree(GetProcessHeap(), 0, name);
472 ret = pGetComputerNameExA(ComputerNameDnsHostname, (LPSTR)0xdeadbeef, &size);
473 error = GetLastError();
474 ok(ret == 0, "Expected 0, got %d\n", ret);
475 ok(error == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", error);
477 /* size is not set in win2k */
479 size = MAX_COMP_NAME;
480 name = HeapAlloc(GetProcessHeap(), 0, size * sizeof(name[0]));
481 ok(name != NULL, "HeapAlloc failed with error %d\n", GetLastError());
482 ret = pGetComputerNameExA(ComputerNameDnsHostname, name, &size);
483 ok(ret, "GetComputerNameExA(ComputerNameDnsHostname) failed with error %d\n", GetLastError());
484 trace("hostname is \"%s\"\n", name);
485 HeapFree(GetProcessHeap(), 0, name);
488 ret = pGetComputerNameExA(ComputerNameNetBIOS, (LPSTR)0xdeadbeef, &size);
489 error = GetLastError();
490 ok(ret == 0, "Expected 0, got %d\n", ret);
491 ok(error == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", error);
493 /* size is not set in win2k */
495 size = MAX_COMP_NAME;
496 name = HeapAlloc(GetProcessHeap(), 0, size * sizeof(name[0]));
497 ok(name != NULL, "HeapAlloc failed with error %d\n", GetLastError());
498 ret = pGetComputerNameExA(ComputerNameNetBIOS, name, &size);
499 ok(ret, "GetComputerNameExA(ComputerNameNetBIOS) failed with error %d\n", GetLastError());
500 trace("NetBIOS name is \"%s\"\n", name);
501 HeapFree(GetProcessHeap(), 0, name);
504 static void test_GetComputerNameExW(void)
511 if (!pGetComputerNameExW)
513 win_skip("GetComputerNameExW function not implemented\n");
518 ret = pGetComputerNameExW(ComputerNameDnsDomain, (LPWSTR)0xdeadbeef, &size);
519 error = GetLastError();
520 ok(!ret && error == ERROR_MORE_DATA, "GetComputerNameExW should have failed with ERROR_MORE_DATA instead of %d\n", error);
521 nameW = HeapAlloc(GetProcessHeap(), 0, size * sizeof(nameW[0]));
522 ok(nameW != NULL, "HeapAlloc failed with error %d\n", GetLastError());
523 ret = pGetComputerNameExW(ComputerNameDnsDomain, nameW, &size);
524 ok(ret, "GetComputerNameExW(ComputerNameDnsDomain) failed with error %d\n", GetLastError());
525 HeapFree(GetProcessHeap(), 0, nameW);
528 ret = pGetComputerNameExW(ComputerNameDnsFullyQualified, (LPWSTR)0xdeadbeef, &size);
529 error = GetLastError();
530 ok(!ret && error == ERROR_MORE_DATA, "GetComputerNameExW should have failed with ERROR_MORE_DATA instead of %d\n", error);
531 nameW = HeapAlloc(GetProcessHeap(), 0, size * sizeof(nameW[0]));
532 ok(nameW != NULL, "HeapAlloc failed with error %d\n", GetLastError());
533 ret = pGetComputerNameExW(ComputerNameDnsFullyQualified, nameW, &size);
534 ok(ret, "GetComputerNameExW(ComputerNameDnsFullyQualified) failed with error %d\n", GetLastError());
535 HeapFree(GetProcessHeap(), 0, nameW);
538 ret = pGetComputerNameExW(ComputerNameDnsHostname, (LPWSTR)0xdeadbeef, &size);
539 error = GetLastError();
540 ok(!ret && error == ERROR_MORE_DATA, "GetComputerNameExW should have failed with ERROR_MORE_DATA instead of %d\n", error);
541 nameW = HeapAlloc(GetProcessHeap(), 0, size * sizeof(nameW[0]));
542 ok(nameW != NULL, "HeapAlloc failed with error %d\n", GetLastError());
543 ret = pGetComputerNameExW(ComputerNameDnsHostname, nameW, &size);
544 ok(ret, "GetComputerNameExW(ComputerNameDnsHostname) failed with error %d\n", GetLastError());
545 HeapFree(GetProcessHeap(), 0, nameW);
548 ret = pGetComputerNameExW(ComputerNameNetBIOS, (LPWSTR)0xdeadbeef, &size);
549 error = GetLastError();
550 ok(!ret && error == ERROR_MORE_DATA, "GetComputerNameExW should have failed with ERROR_MORE_DATA instead of %d\n", error);
551 nameW = HeapAlloc(GetProcessHeap(), 0, size * sizeof(nameW[0]));
552 ok(nameW != NULL, "HeapAlloc failed with error %d\n", GetLastError());
553 ret = pGetComputerNameExW(ComputerNameNetBIOS, nameW, &size);
554 ok(ret, "GetComputerNameExW(ComputerNameNetBIOS) failed with error %d\n", GetLastError());
555 HeapFree(GetProcessHeap(), 0, nameW);
560 init_functionpointers();
563 test_GetSetEnvironmentVariableA();
564 test_GetSetEnvironmentVariableW();
565 test_ExpandEnvironmentStringsA();
566 test_GetComputerName();
567 test_GetComputerNameExA();
568 test_GetComputerNameExW();