2 * Unit tests for profile functions
4 * Copyright (c) 2003 Stefan Leichter
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
24 #include "wine/test.h"
29 #define KEY "ProfileInt"
30 #define SECTION "Test"
31 #define TESTFILE ".\\testwine.ini"
32 #define TESTFILE2 ".\\testwine2.ini"
44 static void test_profile_int(void)
46 struct _profileInt profileInt[]={
47 { NULL, NULL, NULL, NULL, 70, 0 , 0}, /* 0 */
48 { NULL, NULL, NULL, TESTFILE, -1, 4294967295U, 0},
49 { NULL, NULL, NULL, TESTFILE, 1, 1 , 0},
50 { SECTION, NULL, NULL, TESTFILE, -1, 4294967295U, 0},
51 { SECTION, NULL, NULL, TESTFILE, 1, 1 , 0},
52 { NULL, KEY, NULL, TESTFILE, -1, 4294967295U, 0}, /* 5 */
53 { NULL, KEY, NULL, TESTFILE, 1, 1 , 0},
54 { SECTION, KEY, NULL, TESTFILE, -1, 4294967295U, 4294967295U},
55 { SECTION, KEY, NULL, TESTFILE, 1, 1 , 1},
56 { SECTION, KEY, "-1", TESTFILE, -1, 4294967295U, 4294967295U},
57 { SECTION, KEY, "-1", TESTFILE, 1, 4294967295U, 4294967295U}, /* 10 */
58 { SECTION, KEY, "1", TESTFILE, -1, 1 , 1},
59 { SECTION, KEY, "1", TESTFILE, 1, 1 , 1},
60 { SECTION, KEY, "+1", TESTFILE, -1, 1 , 0},
61 { SECTION, KEY, "+1", TESTFILE, 1, 1 , 0},
62 { SECTION, KEY, "4294967296", TESTFILE, -1, 0 , 0}, /* 15 */
63 { SECTION, KEY, "4294967296", TESTFILE, 1, 0 , 0},
64 { SECTION, KEY, "4294967297", TESTFILE, -1, 1 , 1},
65 { SECTION, KEY, "4294967297", TESTFILE, 1, 1 , 1},
66 { SECTION, KEY, "-4294967297", TESTFILE, -1, 4294967295U, 4294967295U},
67 { SECTION, KEY, "-4294967297", TESTFILE, 1, 4294967295U, 4294967295U}, /* 20 */
68 { SECTION, KEY, "42A94967297", TESTFILE, -1, 42 , 42},
69 { SECTION, KEY, "42A94967297", TESTFILE, 1, 42 , 42},
70 { SECTION, KEY, "B4294967297", TESTFILE, -1, 0 , 0},
71 { SECTION, KEY, "B4294967297", TESTFILE, 1, 0 , 0},
73 int i, num_test = (sizeof(profileInt)/sizeof(struct _profileInt));
76 DeleteFileA( TESTFILE);
78 for (i=0; i < num_test; i++) {
79 if (profileInt[i].value)
80 WritePrivateProfileStringA(SECTION, KEY, profileInt[i].value,
81 profileInt[i].iniFile);
83 res = GetPrivateProfileIntA(profileInt[i].section, profileInt[i].key,
84 profileInt[i].defaultVal, profileInt[i].iniFile);
85 ok((res == profileInt[i].result) || (res == profileInt[i].result9x),
86 "test<%02d>: ret<%010u> exp<%010u><%010u>\n",
87 i, res, profileInt[i].result, profileInt[i].result9x);
90 DeleteFileA( TESTFILE);
93 static void test_profile_string(void)
95 static WCHAR emptyW[] = { 0 };
96 static WCHAR keyW[] = { 'k','e','y',0 };
97 static WCHAR sW[] = { 's',0 };
98 static WCHAR TESTFILE2W[] = {'.','\\','t','e','s','t','w','i','n','e','2','.','i','n','i',0};
99 static WCHAR valsectionW[] = {'v','a','l','_','e','_','s','e','c','t','i','o','n',0 };
100 static WCHAR valnokeyW[] = {'v','a','l','_','n','o','_','k','e','y',0};
107 /* test that lines without an '=' will not be enumerated */
108 /* in the case below, name2 is a key while name3 is not. */
109 char content[]="[s]\r\nname1=val1\r\nname2=\r\nname3\r\nname4=val4\r\n";
110 char content2[]="\r\nkey=val_no_section\r\n[]\r\nkey=val_e_section\r\n"
111 "[s]\r\n=val_no_key\r\n[t]\r\n";
112 DeleteFileA( TESTFILE2);
113 h = CreateFileA( TESTFILE2, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
114 FILE_ATTRIBUTE_NORMAL, NULL);
115 ok( h != INVALID_HANDLE_VALUE, " cannot create %s\n", TESTFILE2);
116 if( h == INVALID_HANDLE_VALUE) return;
117 WriteFile( h, content, sizeof(content), &count, NULL);
120 /* enumerate the keys */
121 ret=GetPrivateProfileStringA( "s", NULL, "", buf, sizeof(buf),
123 for( p = buf + strlen(buf) + 1; *p;p += strlen(p)+1)
126 ok( ret == 18 && !strcmp( buf, "name1,name2,name4"), "wrong keys returned(%d): %s\n", ret,
129 /* add a new key to test that the file is quite usable */
130 WritePrivateProfileStringA( "s", "name5", "val5", TESTFILE2);
131 ret=GetPrivateProfileStringA( "s", NULL, "", buf, sizeof(buf),
133 for( p = buf + strlen(buf) + 1; *p;p += strlen(p)+1)
135 ok( ret == 24 && !strcmp( buf, "name1,name2,name4,name5"), "wrong keys returned(%d): %s\n",
138 h = CreateFileA( TESTFILE2, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
139 FILE_ATTRIBUTE_NORMAL, NULL);
140 ok( h != INVALID_HANDLE_VALUE, " cannot create %s\n", TESTFILE2);
141 if( h == INVALID_HANDLE_VALUE) return;
142 WriteFile( h, content2, sizeof(content2), &count, NULL);
145 /* works only in unicode, ascii crashes */
146 ret=GetPrivateProfileStringW(emptyW, keyW, emptyW, bufW,
147 sizeof(bufW)/sizeof(bufW[0]), TESTFILE2W);
149 ok(ret == 13, "expected 13, got %u\n", ret);
151 ok(!lstrcmpW(valsectionW,bufW), "expected %s, got %s\n",
152 wine_dbgstr_w(valsectionW), wine_dbgstr_w(bufW) );
154 /* works only in unicode, ascii crashes */
155 ret=GetPrivateProfileStringW(sW, emptyW, emptyW, bufW,
156 sizeof(bufW)/sizeof(bufW[0]), TESTFILE2W);
158 ok(ret == 10, "expected 10, got %u\n", ret);
160 ok(!lstrcmpW(valnokeyW,bufW), "expected %s, got %s\n",
161 wine_dbgstr_w(valnokeyW), wine_dbgstr_w(bufW) );
163 DeleteFileA( TESTFILE2);
166 static void test_profile_sections(void)
173 static const char content[]="[section1]\r\nname1=val1\r\nname2=\r\nname3\r\nname4=val4\r\n[section2]\r\n";
174 static const char testfile4[]=".\\testwine4.ini";
175 BOOL on_win98 = FALSE;
177 DeleteFileA( testfile4 );
178 h = CreateFileA( testfile4, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
179 ok( h != INVALID_HANDLE_VALUE, " cannot create %s\n", testfile4);
180 if( h == INVALID_HANDLE_VALUE) return;
181 WriteFile( h, content, sizeof(content), &count, NULL);
184 /* Some parameter checking */
185 SetLastError(0xdeadbeef);
186 ret = GetPrivateProfileSectionA( NULL, NULL, 0, NULL );
187 ok( ret == 0, "expected return size 0, got %d\n", ret );
188 ok( GetLastError() == ERROR_INVALID_PARAMETER ||
189 GetLastError() == 0xdeadbeef /* Win98 */,
190 "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
191 if (GetLastError() == 0xdeadbeef) on_win98 = TRUE;
193 SetLastError(0xdeadbeef);
194 ret = GetPrivateProfileSectionA( NULL, NULL, 0, testfile4 );
195 ok( ret == 0, "expected return size 0, got %d\n", ret );
196 ok( GetLastError() == ERROR_INVALID_PARAMETER ||
197 GetLastError() == 0xdeadbeef /* Win98 */,
198 "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
202 SetLastError(0xdeadbeef);
203 ret = GetPrivateProfileSectionA( "section1", NULL, 0, testfile4 );
204 ok( ret == 0, "expected return size 0, got %d\n", ret );
205 ok( GetLastError() == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
208 SetLastError(0xdeadbeef);
209 ret = GetPrivateProfileSectionA( NULL, buf, sizeof(buf), testfile4 );
210 ok( ret == 0, "expected return size 0, got %d\n", ret );
211 ok( GetLastError() == ERROR_INVALID_PARAMETER ||
212 broken(GetLastError() == 0xdeadbeef), /* Win9x, WinME */
213 "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
215 SetLastError(0xdeadbeef);
216 ret = GetPrivateProfileSectionA( "section1", buf, sizeof(buf), NULL );
217 ok( ret == 0, "expected return size 0, got %d\n", ret );
219 ok( GetLastError() == ERROR_FILE_NOT_FOUND ||
220 broken(GetLastError() == 0xdeadbeef), /* Win9x, WinME */
221 "expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError());
223 /* Existing empty section with no keys */
224 SetLastError(0xdeadbeef);
225 ret=GetPrivateProfileSectionA("section2", buf, sizeof(buf), testfile4);
226 ok( ret == 0, "expected return size 0, got %d\n", ret );
227 ok( GetLastError() == ERROR_SUCCESS ||
228 broken(GetLastError() == 0xdeadbeef), /* Win9x, WinME */
229 "expected ERROR_SUCCESS, got %d\n", GetLastError());
231 /* Existing section with keys and values*/
232 SetLastError(0xdeadbeef);
233 ret=GetPrivateProfileSectionA("section1", buf, sizeof(buf), testfile4);
234 for( p = buf + strlen(buf) + 1; *p;p += strlen(p)+1)
236 ok( ret == 35 && !strcmp( buf, "name1=val1,name2=,name3,name4=val4"), "wrong section returned(%d): %s\n",
238 ok( buf[ret-1] == 0 && buf[ret] == 0, "returned buffer not terminated with double-null\n" );
239 ok( GetLastError() == ERROR_SUCCESS ||
240 broken(GetLastError() == 0xdeadbeef), /* Win9x, WinME */
241 "expected ERROR_SUCCESS, got %d\n", GetLastError());
244 ret=GetPrivateProfileSectionA("section1", buf, 24, testfile4);
245 for( p = buf + strlen(buf) + 1; *p;p += strlen(p)+1)
247 ok( ret == 22 && !strcmp( buf, "name1=val1,name2=,name"), "wrong section returned(%d): %s\n",
249 ok( buf[ret] == 0 && buf[ret+1] == 0, "returned buffer not terminated with double-null\n" );
251 DeleteFileA( testfile4 );
254 static void test_profile_sections_names(void)
261 static const char content[]="[section1]\r\n[section2]\r\n[section3]\r\n";
262 static const char testfile3[]=".\\testwine3.ini";
263 static const WCHAR testfile3W[]={ '.','\\','t','e','s','t','w','i','n','e','3','.','i','n','i',0 };
264 static const WCHAR not_here[] = {'.','\\','n','o','t','_','h','e','r','e','.','i','n','i',0};
265 DeleteFileA( testfile3 );
266 h = CreateFileA( testfile3, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
267 FILE_ATTRIBUTE_NORMAL, NULL);
268 ok( h != INVALID_HANDLE_VALUE, " cannot create %s\n", testfile3);
269 if( h == INVALID_HANDLE_VALUE) return;
270 WriteFile( h, content, sizeof(content), &count, NULL);
273 /* Test with sufficiently large buffer */
274 memset(buf, 0xc, sizeof(buf));
275 ret = GetPrivateProfileSectionNamesA( buf, 29, testfile3 );
277 broken(ret == 28), /* Win9x, WinME */
278 "expected return size 27, got %d\n", ret );
279 ok( (buf[ret-1] == 0 && buf[ret] == 0) ||
280 broken(buf[ret-1] == 0 && buf[ret-2] == 0), /* Win9x, WinME */
281 "returned buffer not terminated with double-null\n" );
283 /* Test with exactly fitting buffer */
284 memset(buf, 0xc, sizeof(buf));
285 ret = GetPrivateProfileSectionNamesA( buf, 28, testfile3 );
287 broken(ret == 28), /* Win9x, WinME */
288 "expected return size 26, got %d\n", ret );
290 ok( (buf[ret+1] == 0 && buf[ret] == 0) || /* W2K3 and higher */
291 broken(buf[ret+1] == 0xc && buf[ret] == 0) || /* NT4, W2K, WinXP */
292 broken(buf[ret-1] == 0 && buf[ret-2] == 0), /* Win9x, WinME */
293 "returned buffer not terminated with double-null\n" );
295 /* Test with a buffer too small */
296 memset(buf, 0xc, sizeof(buf));
297 ret = GetPrivateProfileSectionNamesA( buf, 27, testfile3 );
298 ok( ret == 25, "expected return size 25, got %d\n", ret );
299 /* Win9x and WinME only fills the buffer with complete section names (double-null terminated) */
300 count = strlen("section1") + sizeof(CHAR) + strlen("section2");
302 ok( (buf[ret+1] == 0 && buf[ret] == 0) ||
303 broken(buf[count] == 0 && buf[count+1] == 0), /* Win9x, WinME */
304 "returned buffer not terminated with double-null\n" );
306 /* Tests on nonexistent file */
307 memset(buf, 0xc, sizeof(buf));
308 ret = GetPrivateProfileSectionNamesA( buf, 10, ".\\not_here.ini" );
310 broken(ret == 1), /* Win9x, WinME */
311 "expected return size 0, got %d\n", ret );
312 ok( buf[0] == 0, "returned buffer not terminated with null\n" );
313 ok( buf[1] != 0, "returned buffer terminated with double-null\n" );
315 /* Test with sufficiently large buffer */
316 SetLastError(0xdeadbeef);
317 memset(bufW, 0xcc, sizeof(bufW));
318 ret = GetPrivateProfileSectionNamesW( bufW, 29, testfile3W );
319 if (ret == 0 && (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED))
321 win_skip("GetPrivateProfileSectionNamesW is not implemented\n");
322 DeleteFileA( testfile3 );
325 ok( ret == 27, "expected return size 27, got %d\n", ret );
326 ok( bufW[ret-1] == 0 && bufW[ret] == 0, "returned buffer not terminated with double-null\n" );
328 /* Test with exactly fitting buffer */
329 memset(bufW, 0xcc, sizeof(bufW));
330 ret = GetPrivateProfileSectionNamesW( bufW, 28, testfile3W );
331 ok( ret == 26, "expected return size 26, got %d\n", ret );
332 ok( (bufW[ret+1] == 0 && bufW[ret] == 0) || /* W2K3 and higher */
333 broken(bufW[ret+1] == 0xcccc && bufW[ret] == 0), /* NT4, W2K, WinXP */
334 "returned buffer not terminated with double-null\n" );
336 /* Test with a buffer too small */
337 memset(bufW, 0xcc, sizeof(bufW));
338 ret = GetPrivateProfileSectionNamesW( bufW, 27, testfile3W );
339 ok( ret == 25, "expected return size 25, got %d\n", ret );
340 ok( bufW[ret+1] == 0 && bufW[ret] == 0, "returned buffer not terminated with double-null\n" );
342 DeleteFileA( testfile3 );
344 /* Tests on nonexistent file */
345 memset(bufW, 0xcc, sizeof(bufW));
346 ret = GetPrivateProfileSectionNamesW( bufW, 10, not_here );
347 ok( ret == 0, "expected return size 0, got %d\n", ret );
348 ok( bufW[0] == 0, "returned buffer not terminated with null\n" );
349 ok( bufW[1] != 0, "returned buffer terminated with double-null\n" );
352 /* If the ini-file has already been opened with CreateFile, WritePrivateProfileString failed in wine with an error ERROR_SHARING_VIOLATION, some testing here */
353 static void test_profile_existing(void)
355 static const char *testfile1 = ".\\winesharing1.ini";
356 static const char *testfile2 = ".\\winesharing2.ini";
358 static const struct {
359 DWORD dwDesiredAccess;
365 {GENERIC_READ, FILE_SHARE_READ, ERROR_SHARING_VIOLATION, FALSE },
366 {GENERIC_READ, FILE_SHARE_WRITE, ERROR_SHARING_VIOLATION, TRUE },
367 {GENERIC_WRITE, FILE_SHARE_READ, ERROR_SHARING_VIOLATION, FALSE },
368 {GENERIC_WRITE, FILE_SHARE_WRITE, ERROR_SHARING_VIOLATION, TRUE },
369 {GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ, ERROR_SHARING_VIOLATION, FALSE },
370 {GENERIC_READ|GENERIC_WRITE, FILE_SHARE_WRITE, ERROR_SHARING_VIOLATION, TRUE },
371 {GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, 0, FALSE, ERROR_SHARING_VIOLATION /* nt4 */},
372 {GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE, 0, FALSE, ERROR_SHARING_VIOLATION /* nt4 */},
373 /*Thief demo (bug 5024) opens .ini file like this*/
374 {GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE, 0, FALSE, ERROR_SHARING_VIOLATION /* nt4 */}
381 char buffer[MAX_PATH];
383 for (i=0; i < sizeof(pe)/sizeof(pe[0]); i++)
385 h = CreateFile(testfile1, pe[i].dwDesiredAccess, pe[i].dwShareMode, NULL,
386 CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
387 ok(INVALID_HANDLE_VALUE != h, "%d: CreateFile failed\n",i);
388 SetLastError(0xdeadbeef);
390 ret = WritePrivateProfileString(SECTION, KEY, "12345", testfile1);
391 if (!pe[i].write_error)
394 ok( broken(GetLastError() == pe[i].broken_error),
395 "%d: WritePrivateProfileString failed with error %u\n", i, GetLastError() );
397 size = GetPrivateProfileString(SECTION, KEY, 0, buffer, MAX_PATH, testfile1);
399 ok( size == 5, "%d: test failed, number of characters copied: %d instead of 5\n", i, size );
401 ok( !size, "%d: test failed, number of characters copied: %d instead of 0\n", i, size );
405 DWORD err = GetLastError();
406 ok( !ret, "%d: WritePrivateProfileString succeeded\n", i );
408 ok( err == pe[i].write_error, "%d: WritePrivateProfileString failed with error %u/%u\n",
409 i, err, pe[i].write_error );
411 size = GetPrivateProfileString(SECTION, KEY, 0, buffer, MAX_PATH, testfile1);
412 ok( !size, "%d: test failed, number of characters copied: %d instead of 0\n", i, size );
415 ok( DeleteFile(testfile1), "delete failed\n" );
418 h = CreateFile(testfile2, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
419 sprintf( buffer, "[%s]\r\n%s=123\r\n", SECTION, KEY );
420 ok( WriteFile( h, buffer, strlen(buffer), &size, NULL ), "failed to write\n" );
423 for (i=0; i < sizeof(pe)/sizeof(pe[0]); i++)
425 h = CreateFile(testfile2, pe[i].dwDesiredAccess, pe[i].dwShareMode, NULL,
426 OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
427 ok(INVALID_HANDLE_VALUE != h, "%d: CreateFile failed\n",i);
428 SetLastError(0xdeadbeef);
429 ret = GetPrivateProfileStringA(SECTION, KEY, NULL, buffer, MAX_PATH, testfile2);
430 /* Win9x and WinME returns 0 for all cases except the first one */
431 if (!pe[i].read_error)
433 broken(!ret && GetLastError() == 0xdeadbeef), /* Win9x, WinME */
434 "%d: GetPrivateProfileString failed with error %u\n", i, GetLastError() );
436 ok( !ret, "%d: GetPrivateProfileString succeeded\n", i );
439 ok( DeleteFile(testfile2), "delete failed\n" );
442 static void test_profile_delete_on_close(void)
444 static CHAR testfile[] = ".\\testwine5.ini";
447 static const char contents[] = "[" SECTION "]\n" KEY "=123\n";
449 h = CreateFile(testfile, GENERIC_WRITE, FILE_SHARE_READ, NULL,
450 CREATE_ALWAYS, FILE_FLAG_DELETE_ON_CLOSE, NULL);
451 res = WriteFile( h, contents, sizeof contents - 1, &size, NULL );
452 ok( res, "Cannot write test file: %x\n", GetLastError() );
453 ok( size == sizeof contents - 1, "Test file: partial write\n");
455 SetLastError(0xdeadbeef);
456 res = GetPrivateProfileInt(SECTION, KEY, 0, testfile);
458 broken(res == 0 && GetLastError() == ERROR_SHARING_VIOLATION), /* Win9x, WinME */
459 "Got %d instead of 123\n", res);
461 /* This also deletes the file */
465 static void test_profile_refresh(void)
467 static CHAR testfile[] = ".\\winetest4.ini";
470 static const char contents1[] = "[" SECTION "]\n" KEY "=123\n";
471 static const char contents2[] = "[" SECTION "]\n" KEY "=124\n";
473 h = CreateFile(testfile, GENERIC_WRITE, FILE_SHARE_READ, NULL,
474 CREATE_ALWAYS, FILE_FLAG_DELETE_ON_CLOSE, NULL);
475 res = WriteFile( h, contents1, sizeof contents1 - 1, &size, NULL );
476 ok( res, "Cannot write test file: %x\n", GetLastError() );
477 ok( size == sizeof contents1 - 1, "Test file: partial write\n");
479 SetLastError(0xdeadbeef);
480 res = GetPrivateProfileInt(SECTION, KEY, 0, testfile);
482 broken(res == 0 && GetLastError() == ERROR_SHARING_VIOLATION), /* Win9x, WinME */
483 "Got %d instead of 123\n", res);
487 /* Test proper invalidation of wine's profile file cache */
489 h = CreateFile(testfile, GENERIC_WRITE, FILE_SHARE_READ, NULL,
490 CREATE_ALWAYS, FILE_FLAG_DELETE_ON_CLOSE, NULL);
491 res = WriteFile( h, contents2, sizeof contents2 - 1, &size, NULL );
492 ok( res, "Cannot write test file: %x\n", GetLastError() );
493 ok( size == sizeof contents2 - 1, "Test file: partial write\n");
495 SetLastError(0xdeadbeef);
496 res = GetPrivateProfileInt(SECTION, KEY, 0, testfile);
498 broken(res == 0 && GetLastError() == 0xdeadbeef), /* Win9x, WinME */
499 "Got %d instead of 124\n", res);
501 /* This also deletes the file */
505 static void create_test_file(LPCSTR name, LPCSTR data, DWORD size)
510 hfile = CreateFileA(name, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
511 ok(hfile != INVALID_HANDLE_VALUE, "cannot create %s\n", name);
512 WriteFile(hfile, data, size, &count, NULL);
516 static BOOL emptystr_ok(CHAR emptystr[MAX_PATH])
520 for(i = 0;i < MAX_PATH;++i)
523 trace("emptystr[%d] = %d\n",i,emptystr[i]);
530 static void test_GetPrivateProfileString(const char *content, const char *descript)
534 CHAR def_val[MAX_PATH];
536 CHAR windir[MAX_PATH];
537 /* NT series crashes on r/o empty strings, so pass an r/w
538 empty string and check for modification */
539 CHAR emptystr[MAX_PATH] = "";
542 static const char filename[] = ".\\winetest.ini";
544 trace("test_GetPrivateProfileStringA: %s\n", descript);
546 if(!lstrcmpA(descript, "CR only"))
548 SetLastError(0xdeadbeef);
549 ret = GetPrivateProfileStringW(NULL, NULL, NULL,
551 if (!ret && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
553 win_skip("Win9x and WinME don't handle 'CR only' correctly\n");
558 create_test_file(filename, content, lstrlenA(content));
560 /* Run this test series with caching. Wine won't cache profile
561 files younger than 2.1 seconds. */
564 /* lpAppName is NULL */
565 memset(buf, 0xc, sizeof(buf));
566 lstrcpyA(buf, "kumquat");
567 ret = GetPrivateProfileStringA(NULL, "name1", "default",
568 buf, MAX_PATH, filename);
570 broken(ret == 19), /* Win9x and WinME */
571 "Expected 18, got %d\n", ret);
572 len = lstrlenA("section1") + sizeof(CHAR) + lstrlenA("section2") + 2 * sizeof(CHAR);
573 ok(!memcmp(buf, "section1\0section2\0\0", len),
574 "Expected \"section1\\0section2\\0\\0\", got \"%s\"\n", buf);
576 /* lpAppName is empty */
577 memset(buf, 0xc, sizeof(buf));
578 lstrcpyA(buf, "kumquat");
579 ret = GetPrivateProfileStringA(emptystr, "name1", "default",
580 buf, MAX_PATH, filename);
581 ok(ret == 7, "Expected 7, got %d\n", ret);
582 ok(!lstrcmpA(buf, "default"), "Expected \"default\", got \"%s\"\n", buf);
583 ok(emptystr_ok(emptystr), "AppName modified\n");
585 /* lpAppName is missing */
586 memset(buf, 0xc,sizeof(buf));
587 lstrcpyA(buf, "kumquat");
588 ret = GetPrivateProfileStringA("notasection", "name1", "default",
589 buf, MAX_PATH, filename);
590 ok(ret == 7, "Expected 7, got %d\n", ret);
591 ok(!lstrcmpA(buf, "default"), "Expected \"default\", got \"%s\"\n", buf);
593 /* lpAppName is empty, lpDefault is NULL */
594 memset(buf, 0xc,sizeof(buf));
595 lstrcpyA(buf, "kumquat");
596 ret = GetPrivateProfileStringA(emptystr, "name1", NULL,
597 buf, MAX_PATH, filename);
598 ok(ret == 0, "Expected 0, got %d\n", ret);
599 ok(!lstrcmpA(buf, "") ||
600 broken(!lstrcmpA(buf, "kumquat")), /* Win9x, WinME */
601 "Expected \"\", got \"%s\"\n", buf);
602 ok(emptystr_ok(emptystr), "AppName modified\n");
604 /* lpAppName is empty, lpDefault is empty */
605 memset(buf, 0xc,sizeof(buf));
606 lstrcpyA(buf, "kumquat");
607 ret = GetPrivateProfileStringA(emptystr, "name1", "",
608 buf, MAX_PATH, filename);
609 ok(ret == 0, "Expected 0, got %d\n", ret);
610 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
611 ok(emptystr_ok(emptystr), "AppName modified\n");
613 /* lpAppName is empty, lpDefault has trailing blank characters */
614 memset(buf, 0xc,sizeof(buf));
615 lstrcpyA(buf, "kumquat");
616 /* lpDefault must be writable (trailing blanks are removed inplace in win9x) */
617 lstrcpyA(def_val, "default ");
618 ret = GetPrivateProfileStringA(emptystr, "name1", def_val,
619 buf, MAX_PATH, filename);
620 ok(ret == 7, "Expected 7, got %d\n", ret);
621 ok(!lstrcmpA(buf, "default"), "Expected \"default\", got \"%s\"\n", buf);
622 ok(emptystr_ok(emptystr), "AppName modified\n");
624 /* lpAppName is empty, many blank characters in lpDefault */
625 memset(buf, 0xc,sizeof(buf));
626 lstrcpyA(buf, "kumquat");
627 /* lpDefault must be writable (trailing blanks are removed inplace in win9x) */
628 lstrcpyA(def_val, "one two ");
629 ret = GetPrivateProfileStringA(emptystr, "name1", def_val,
630 buf, MAX_PATH, filename);
631 ok(ret == 7, "Expected 7, got %d\n", ret);
632 ok(!lstrcmpA(buf, "one two"), "Expected \"one two\", got \"%s\"\n", buf);
633 ok(emptystr_ok(emptystr), "AppName modified\n");
635 /* lpAppName is empty, blank character but not trailing in lpDefault */
636 memset(buf, 0xc,sizeof(buf));
637 lstrcpyA(buf, "kumquat");
638 ret = GetPrivateProfileStringA(emptystr, "name1", "one two",
639 buf, MAX_PATH, filename);
640 ok(ret == 7, "Expected 7, got %d\n", ret);
641 ok(!lstrcmpA(buf, "one two"), "Expected \"one two\", got \"%s\"\n", buf);
642 ok(emptystr_ok(emptystr), "AppName modified\n");
644 /* lpKeyName is NULL */
645 memset(buf, 0xc,sizeof(buf));
646 lstrcpyA(buf, "kumquat");
647 ret = GetPrivateProfileStringA("section1", NULL, "default",
648 buf, MAX_PATH, filename);
649 ok(ret == 18, "Expected 18, got %d\n", ret);
650 ok(!memcmp(buf, "name1\0name2\0name4\0", ret + 1),
651 "Expected \"name1\\0name2\\0name4\\0\", got \"%s\"\n", buf);
653 /* lpKeyName is empty */
654 memset(buf, 0xc,sizeof(buf));
655 lstrcpyA(buf, "kumquat");
656 ret = GetPrivateProfileStringA("section1", emptystr, "default",
657 buf, MAX_PATH, filename);
658 ok(ret == 7, "Expected 7, got %d\n", ret);
659 ok(!lstrcmpA(buf, "default"), "Expected \"default\", got \"%s\"\n", buf);
660 ok(emptystr_ok(emptystr), "KeyName modified\n");
662 /* lpKeyName is missing */
663 memset(buf, 0xc,sizeof(buf));
664 lstrcpyA(buf, "kumquat");
665 ret = GetPrivateProfileStringA("section1", "notakey", "default",
666 buf, MAX_PATH, filename);
667 ok(ret == 7, "Expected 7, got %d\n", ret);
668 ok(!lstrcmpA(buf, "default"), "Expected \"default\", got \"%s\"\n", buf);
670 /* lpKeyName is empty, lpDefault is NULL */
671 memset(buf, 0xc,sizeof(buf));
672 lstrcpyA(buf, "kumquat");
673 ret = GetPrivateProfileStringA("section1", emptystr, NULL,
674 buf, MAX_PATH, filename);
675 ok(ret == 0, "Expected 0, got %d\n", ret);
676 ok(!lstrcmpA(buf, "") ||
677 broken(!lstrcmpA(buf, "kumquat")), /* Win9x, WinME */
678 "Expected \"\", got \"%s\"\n", buf);
679 ok(emptystr_ok(emptystr), "KeyName modified\n");
681 /* lpKeyName is empty, lpDefault is empty */
682 memset(buf, 0xc,sizeof(buf));
683 lstrcpyA(buf, "kumquat");
684 ret = GetPrivateProfileStringA("section1", emptystr, "",
685 buf, MAX_PATH, filename);
686 ok(ret == 0, "Expected 0, got %d\n", ret);
687 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
688 ok(emptystr_ok(emptystr), "KeyName modified\n");
690 /* lpKeyName is empty, lpDefault has trailing blank characters */
691 memset(buf, 0xc,sizeof(buf));
692 lstrcpyA(buf, "kumquat");
693 /* lpDefault must be writable (trailing blanks are removed inplace in win9x) */
694 lstrcpyA(def_val, "default ");
695 ret = GetPrivateProfileStringA("section1", emptystr, def_val,
696 buf, MAX_PATH, filename);
697 ok(ret == 7, "Expected 7, got %d\n", ret);
698 ok(!lstrcmpA(buf, "default"), "Expected \"default\", got \"%s\"\n", buf);
699 ok(emptystr_ok(emptystr), "KeyName modified\n");
703 /* lpReturnedString is NULL */
704 ret = GetPrivateProfileStringA("section1", "name1", "default",
705 NULL, MAX_PATH, filename);
708 /* lpFileName is NULL */
709 memset(buf, 0xc,sizeof(buf));
710 lstrcpyA(buf, "kumquat");
711 ret = GetPrivateProfileStringA("section1", "name1", "default",
712 buf, MAX_PATH, NULL);
714 broken(ret == 0), /* Win9x, WinME */
715 "Expected 7, got %d\n", ret);
716 ok(!lstrcmpA(buf, "default") ||
717 broken(!lstrcmpA(buf, "kumquat")), /* Win9x, WinME */
718 "Expected \"default\", got \"%s\"\n", buf);
720 /* lpFileName is empty */
721 memset(buf, 0xc,sizeof(buf));
722 lstrcpyA(buf, "kumquat");
723 ret = GetPrivateProfileStringA("section1", "name1", "default",
725 ok(ret == 7, "Expected 7, got %d\n", ret);
726 ok(!lstrcmpA(buf, "default"), "Expected \"default\", got \"%s\"\n", buf);
728 /* lpFileName is nonexistent */
729 memset(buf, 0xc,sizeof(buf));
730 lstrcpyA(buf, "kumquat");
731 ret = GetPrivateProfileStringA("section1", "name1", "default",
732 buf, MAX_PATH, "nonexistent");
733 ok(ret == 7, "Expected 7, got %d\n", ret);
734 ok(!lstrcmpA(buf, "default"), "Expected \"default\", got \"%s\"\n", buf);
737 memset(buf, 0xc,sizeof(buf));
738 lstrcpyA(buf, "kumquat");
739 ret = GetPrivateProfileStringA("section1", "name1", "default",
741 ok(ret == 0, "Expected 0, got %d\n", ret);
742 ok(!lstrcmpA(buf, "kumquat"), "Expected buf to be unchanged, got \"%s\"\n", buf);
744 /* nSize is exact size of output */
745 memset(buf, 0xc,sizeof(buf));
746 lstrcpyA(buf, "kumquat");
747 ret = GetPrivateProfileStringA("section1", "name1", "default",
749 ok(ret == 3, "Expected 3, got %d\n", ret);
750 ok(!lstrcmpA(buf, "val"), "Expected \"val\", got \"%s\"\n", buf);
752 /* nSize has room for NULL terminator */
753 memset(buf, 0xc,sizeof(buf));
754 lstrcpyA(buf, "kumquat");
755 ret = GetPrivateProfileStringA("section1", "name1", "default",
757 ok(ret == 4, "Expected 4, got %d\n", ret);
758 ok(!lstrcmpA(buf, "val1"), "Expected \"val1\", got \"%s\"\n", buf);
760 /* output is 1 character */
761 memset(buf, 0xc,sizeof(buf));
762 lstrcpyA(buf, "kumquat");
763 ret = GetPrivateProfileStringA("section1", "name4", "default",
764 buf, MAX_PATH, filename);
765 ok(ret == 1, "Expected 1, got %d\n", ret);
766 ok(!lstrcmpA(buf, "a"), "Expected \"a\", got \"%s\"\n", buf);
768 /* output is 1 character, no room for NULL terminator */
769 memset(buf, 0xc,sizeof(buf));
770 lstrcpyA(buf, "kumquat");
771 ret = GetPrivateProfileStringA("section1", "name4", "default",
773 ok(ret == 0, "Expected 0, got %d\n", ret);
774 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
776 /* lpAppName is NULL, not enough room for final section name */
777 memset(buf, 0xc,sizeof(buf));
778 lstrcpyA(buf, "kumquat");
779 ret = GetPrivateProfileStringA(NULL, "name1", "default",
781 ok(ret == 14, "Expected 14, got %d\n", ret);
782 len = lstrlenA("section1") + 2 * sizeof(CHAR);
784 ok(!memcmp(buf, "section1\0secti\0\0", ret + 2) ||
785 broken(!memcmp(buf, "section1\0\0", len)), /* Win9x, WinME */
786 "Expected \"section1\\0secti\\0\\0\", got \"%s\"\n", buf);
788 /* lpKeyName is NULL, not enough room for final key name */
789 memset(buf, 0xc,sizeof(buf));
790 lstrcpyA(buf, "kumquat");
791 ret = GetPrivateProfileStringA("section1", NULL, "default",
793 ok(ret == 14, "Expected 14, got %d\n", ret);
795 ok(!memcmp(buf, "name1\0name2\0na\0\0", ret + 2) ||
796 broken(!memcmp(buf, "name1\0name2\0n\0\0", ret + 1)), /* Win9x, WinME */
797 "Expected \"name1\\0name2\\0na\\0\\0\", got \"%s\"\n", buf);
799 /* key value has quotation marks which are stripped */
800 memset(buf, 0xc,sizeof(buf));
801 lstrcpyA(buf, "kumquat");
802 ret = GetPrivateProfileStringA("section1", "name2", "default",
803 buf, MAX_PATH, filename);
804 ok(ret == 4, "Expected 4, got %d\n", ret);
805 ok(!lstrcmpA(buf, "val2"), "Expected \"val2\", got \"%s\"\n", buf);
807 /* case does not match */
808 memset(buf, 0xc,sizeof(buf));
809 lstrcpyA(buf, "kumquat");
810 ret = GetPrivateProfileStringA("section1", "NaMe1", "default",
811 buf, MAX_PATH, filename);
812 ok(ret == 4, "Expected 4, got %d\n", ret);
813 ok(!lstrcmpA(buf, "val1"), "Expected \"val1\", got \"%s\"\n", buf);
815 /* only filename is used */
816 memset(buf, 0xc,sizeof(buf));
817 lstrcpyA(buf, "kumquat");
818 ret = GetPrivateProfileStringA("section1", "NaMe1", "default",
819 buf, MAX_PATH, "winetest.ini");
820 ok(ret == 7, "Expected 7, got %d\n", ret);
821 ok(!lstrcmpA(buf, "default"), "Expected \"default\", got \"%s\"\n", buf);
823 GetWindowsDirectoryA(windir, MAX_PATH);
824 SetLastError(0xdeadbeef);
825 ret = GetTempFileNameA(windir, "pre", 0, path);
826 if (!ret && GetLastError() == ERROR_ACCESS_DENIED)
828 skip("Not allowed to create a file in the Windows directory\n");
829 DeleteFileA(filename);
832 tempfile = strrchr(path, '\\') + 1;
833 create_test_file(path, content, lstrlenA(content));
835 /* only filename is used, file exists in windows directory */
836 memset(buf, 0xc,sizeof(buf));
837 lstrcpyA(buf, "kumquat");
838 ret = GetPrivateProfileStringA("section1", "NaMe1", "default",
839 buf, MAX_PATH, tempfile);
840 ok(ret == 4, "Expected 4, got %d\n", ret);
841 ok(!lstrcmpA(buf, "val1"), "Expected \"val1\", got \"%s\"\n", buf);
843 /* successful case */
844 memset(buf, 0xc,sizeof(buf));
845 lstrcpyA(buf, "kumquat");
846 ret = GetPrivateProfileStringA("section1", "name1", "default",
847 buf, MAX_PATH, filename);
848 ok(ret == 4, "Expected 4, got %d\n", ret);
849 ok(!lstrcmpA(buf, "val1"), "Expected \"val1\", got \"%s\"\n", buf);
851 /* Existing section with no keys in an existing file */
852 memset(buf, 0xc,sizeof(buf));
853 SetLastError(0xdeadbeef);
854 ret=GetPrivateProfileStringA("section2", "DoesntExist", "",
855 buf, MAX_PATH, filename);
856 ok( ret == 0, "expected return size 0, got %d\n", ret );
857 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
859 ok( GetLastError() == 0xdeadbeef ||
860 GetLastError() == ERROR_FILE_NOT_FOUND /* Win 7 */,
861 "expected 0xdeadbeef or ERROR_FILE_NOT_FOUND, got %d\n", GetLastError());
865 DeleteFileA(filename);
868 static BOOL check_binary_file_data(LPCSTR path, const VOID *data, DWORD size)
874 file = CreateFileA(path, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0);
875 if (file == INVALID_HANDLE_VALUE)
878 if(size != GetFileSize(file, NULL) )
884 ret = ReadFile(file, buf, size, &size, NULL);
889 return !memcmp(buf, data, size);
892 static BOOL check_file_data(LPCSTR path, LPCSTR data)
894 return check_binary_file_data(path, data, lstrlenA(data));
897 static void test_WritePrivateProfileString(void)
904 SetLastError(0xdeadbeef);
905 ret = WritePrivateProfileStringW(NULL, NULL, NULL, NULL);
906 if (!ret && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
908 /* Win9x/WinME needs (variable) timeouts between tests and even long timeouts don't
909 * guarantee a correct result.
910 * Win9x/WinMe also produces different ini files where there is always a newline before
911 * a section start (except for the first one).
913 win_skip("WritePrivateProfileString on Win9x/WinME is hard to test reliably\n");
917 GetTempPathA(MAX_PATH, temp);
918 GetTempFileNameA(temp, "wine", 0, path);
921 /* path is not created yet */
924 SetLastError(0xdeadbeef);
925 ret = WritePrivateProfileStringA(NULL, "key", "string", path);
926 ok(ret == FALSE, "Expected FALSE, got %d\n", ret);
927 ok(GetLastError() == ERROR_FILE_NOT_FOUND ||
928 broken(GetLastError() == ERROR_INVALID_PARAMETER) || /* NT4 */
929 broken(GetLastError() == 0xdeadbeef), /* Win9x and WinME */
930 "Expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError());
931 ok(GetFileAttributesA(path) == INVALID_FILE_ATTRIBUTES,
932 "Expected path to not exist\n");
934 GetTempFileNameA(temp, "wine", 0, path);
936 /* NULL lpAppName, path exists */
938 SetLastError(0xdeadbeef);
939 ret = WritePrivateProfileStringA(NULL, "key", "string", path);
940 ok(ret == FALSE, "Expected FALSE, got %d\n", ret);
941 ok(GetLastError() == ERROR_FILE_NOT_FOUND ||
942 broken(GetLastError() == ERROR_INVALID_PARAMETER) || /* NT4 */
943 broken(GetLastError() == 0xdeadbeef), /* Win9x and WinME */
944 "Expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError());
945 ok(check_file_data(path, data), "File doesn't match\n");
950 /* empty lpAppName, crashes on NT4 and higher */
953 ret = WritePrivateProfileStringA("", "key", "string", path);
954 ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
955 ok(check_file_data(path, data), "File doesn't match\n");
961 ret = WritePrivateProfileStringA("App", NULL, "string", path);
962 ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
965 ok(check_file_data(path, data), "File doesn't match\n");
971 /* empty lpKeyName, crashes on NT4 and higher */
974 ret = WritePrivateProfileStringA("App", "", "string", path);
975 ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
978 ok(check_file_data(path, data), "File doesn't match\n");
985 ret = WritePrivateProfileStringA("App", "key", NULL, path);
986 ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
989 ok(check_file_data(path, data) ||
990 (broken(GetFileAttributesA(path) == INVALID_FILE_ATTRIBUTES)), /* Win9x and WinME */
991 "File doesn't match\n");
998 ret = WritePrivateProfileStringA("App", "key", "", path);
1000 broken(!ret), /* Win9x and WinME */
1001 "Expected TRUE, got %d\n", ret);
1002 ok(check_file_data(path, data) ||
1003 (broken(GetFileAttributesA(path) == INVALID_FILE_ATTRIBUTES)), /* Win9x and WinME */
1004 "File doesn't match\n");
1007 /* empty lpFileName */
1008 SetLastError(0xdeadbeef);
1009 ret = WritePrivateProfileStringA("App", "key", "string", "");
1010 ok(ret == FALSE, "Expected FALSE, got %d\n", ret);
1011 ok(GetLastError() == ERROR_ACCESS_DENIED ||
1012 broken(GetLastError() == ERROR_PATH_NOT_FOUND), /* Win9x and WinME */
1013 "Expected ERROR_ACCESS_DENIED, got %d\n", GetLastError());
1015 /* The resulting file will be X:\\%WINDIR%\\win1.tmp */
1016 GetWindowsDirectoryA(temp, MAX_PATH);
1017 GetTempFileNameA(temp, "win", 1, path);
1020 /* relative path in lpFileName */
1023 ret = WritePrivateProfileStringA("App", "key", "string", "win1.tmp");
1024 ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
1025 ok(check_file_data(path, data), "File doesn't match\n");
1028 GetTempPathA(MAX_PATH, temp);
1029 GetTempFileNameA(temp, "wine", 0, path);
1031 /* build up an INI file */
1032 WritePrivateProfileStringA("App1", "key1", "string1", path);
1033 WritePrivateProfileStringA("App1", "key2", "string2", path);
1034 WritePrivateProfileStringA("App1", "key3", "string3", path);
1035 WritePrivateProfileStringA("App2", "key4", "string4", path);
1037 /* make an addition and verify the INI */
1046 ret = WritePrivateProfileStringA("App3", "key5", "string5", path);
1047 ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
1048 ok(check_file_data(path, data), "File doesn't match\n");
1050 /* lpString is NULL, key2 key is deleted */
1058 ret = WritePrivateProfileStringA("App1", "key2", NULL, path);
1059 ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
1060 ok(check_file_data(path, data), "File doesn't match\n");
1062 /* try to delete key2 again */
1070 ret = WritePrivateProfileStringA("App1", "key2", NULL, path);
1071 ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
1072 ok(check_file_data(path, data), "File doesn't match\n");
1074 /* lpKeyName is NULL, App1 section is deleted */
1079 ret = WritePrivateProfileStringA("App1", NULL, "string1", path);
1080 ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
1081 ok(check_file_data(path, data), "File doesn't match\n");
1083 /* lpString is not needed to delete a section */
1086 ret = WritePrivateProfileStringA("App2", NULL, NULL, path);
1087 ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
1088 ok(check_file_data(path, data), "File doesn't match\n");
1090 /* leave just the section */
1091 data = "[App3]\r\n";
1092 ret = WritePrivateProfileStringA("App3", "key5", NULL, path);
1093 ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
1094 ok(check_file_data(path, data), "File doesn't match\n");
1097 /* NULLs in file before first section. Should be preserved in output */
1098 data = "Data \0 before \0 first \0 section" /* 31 bytes */
1099 "\r\n[section1]\r\n" /* 14 bytes */
1100 "key1=string1\r\n"; /* 14 bytes */
1101 GetTempFileNameA(temp, "wine", 0, path);
1102 create_test_file(path, data, 31);
1103 ret = WritePrivateProfileStringA("section1", "key1", "string1", path);
1104 ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
1106 ok( check_binary_file_data(path, data, 59) ||
1107 broken( check_binary_file_data(path, /* Windows 9x */
1108 "Data \0 before \0 first \0 section" /* 31 bytes */
1109 "\r\n\r\n[section1]\r\n" /* 14 bytes */
1110 "key1=string1" /* 14 bytes */
1111 , 59)), "File doesn't match\n");
1118 test_profile_string();
1119 test_profile_sections();
1120 test_profile_sections_names();
1121 test_profile_existing();
1122 test_profile_delete_on_close();
1123 test_profile_refresh();
1124 test_GetPrivateProfileString(
1127 "name2=\"val2\"\r\n"
1132 test_GetPrivateProfileString(
1140 test_WritePrivateProfileString();