47
47
#include "commdlg.h"
48
48
#include "mlang.h"
49
49
#include "mshtmhst.h"
50
+ #ifdef __REACTOS__
51
+ #include <shlwapi_undoc.h>
52
+ #endif
50
53
#include "wine/unicode.h"
51
54
#include "wine/debug.h"
52
55
@@ -3288,6 +3291,37 @@ BOOL WINAPI PlaySoundWrapW(LPCWSTR pszSound, HMODULE hmod, DWORD fdwSound)
3288
3291
DWORD WINAPI SHGetIniStringW (LPCWSTR appName , LPCWSTR keyName , LPWSTR out ,
3289
3292
DWORD outLen , LPCWSTR filename )
3290
3293
{
3294
+ #ifdef __REACTOS__
3295
+ WCHAR szSection [MAX_PATH + 2 ];
3296
+ WCHAR szWideBuff [MAX_PATH ];
3297
+ CHAR szUtf7Buff [MAX_PATH ];
3298
+
3299
+ TRACE ("(%s,%s,%p,%08x,%s)\n" , debugstr_w (appName ), debugstr_w (keyName ),
3300
+ out , outLen , debugstr_w (filename ));
3301
+
3302
+ if (outLen == 0 )
3303
+ return 0 ;
3304
+
3305
+ /* Try ".W"-appended section name. See also SHSetIniStringW. */
3306
+ lstrcpynW (szSection , appName , _countof (szSection ) - 2 );
3307
+ lstrcatW (szSection , L".W" );
3308
+ GetPrivateProfileStringW (szSection , keyName , NULL , szWideBuff , _countof (szWideBuff ), filename );
3309
+ if (szWideBuff [0 ] == UNICODE_NULL ) /* It's empty or not found */
3310
+ {
3311
+ /* Try the normal section name */
3312
+ return GetPrivateProfileStringW (appName , keyName , NULL , out , outLen , filename );
3313
+ }
3314
+
3315
+ /* Okay, now ".W" version is valid. Its value is a UTF-7 string in UTF-16 */
3316
+
3317
+ /* szWideBuff --> szUtf7Buff */
3318
+ SHUnicodeToAnsiCP (CP_ACP , szWideBuff , szUtf7Buff , _countof (szUtf7Buff ));
3319
+ szUtf7Buff [_countof (szUtf7Buff ) - 1 ] = ANSI_NULL ;
3320
+
3321
+ /* szUtf7Buff --> out */
3322
+ SHAnsiToUnicodeCP (CP_UTF7 , szUtf7Buff , out , outLen );
3323
+ out [outLen - 1 ] = UNICODE_NULL ;
3324
+ #else
3291
3325
INT ret ;
3292
3326
WCHAR * buf ;
3293
3327
@@ -3310,10 +3344,27 @@ DWORD WINAPI SHGetIniStringW(LPCWSTR appName, LPCWSTR keyName, LPWSTR out,
3310
3344
* out = 0 ;
3311
3345
3312
3346
HeapFree (GetProcessHeap (), 0 , buf );
3347
+ #endif
3313
3348
3314
3349
return strlenW (out );
3315
3350
}
3316
3351
3352
+ #ifdef __REACTOS__
3353
+ static BOOL Is7BitClean (LPCWSTR psz )
3354
+ {
3355
+ if (!psz )
3356
+ return TRUE;
3357
+
3358
+ while (* psz )
3359
+ {
3360
+ if (* psz > 0x7F )
3361
+ return FALSE;
3362
+ ++ psz ;
3363
+ }
3364
+ return TRUE;
3365
+ }
3366
+ #endif
3367
+
3317
3368
/*************************************************************************
3318
3369
* @ [SHLWAPI.295]
3319
3370
*
@@ -3333,10 +3384,63 @@ DWORD WINAPI SHGetIniStringW(LPCWSTR appName, LPCWSTR keyName, LPWSTR out,
3333
3384
BOOL WINAPI SHSetIniStringW (LPCWSTR appName , LPCWSTR keyName , LPCWSTR str ,
3334
3385
LPCWSTR filename )
3335
3386
{
3387
+ #ifdef __REACTOS__
3388
+ WCHAR szSection [MAX_PATH + 2 ];
3389
+ WCHAR szWideBuff [MAX_PATH ];
3390
+ CHAR szUtf7Buff [MAX_PATH ];
3391
+
3392
+ TRACE ("(%s, %p, %s, %s)\n" , debugstr_w (appName ), keyName , debugstr_w (str ),
3393
+ debugstr_w (filename ));
3394
+
3395
+ /* Write a normal profile string. If str was NULL, then key will be deleted */
3396
+ if (!WritePrivateProfileStringW (appName , keyName , str , filename ))
3397
+ return FALSE;
3398
+
3399
+ if (Is7BitClean (str ))
3400
+ {
3401
+ /* Delete ".A" version */
3402
+ lstrcpynW (szSection , appName , _countof (szSection ) - 2 );
3403
+ lstrcatW (szSection , L".A" );
3404
+ WritePrivateProfileStringW (szSection , keyName , NULL , filename );
3405
+
3406
+ /* Delete ".W" version */
3407
+ lstrcpynW (szSection , appName , _countof (szSection ) - 2 );
3408
+ lstrcatW (szSection , L".W" );
3409
+ WritePrivateProfileStringW (szSection , keyName , NULL , filename );
3410
+
3411
+ return TRUE;
3412
+ }
3413
+
3414
+ /* Now str is not 7-bit clean. It needs UTF-7 encoding in UTF-16.
3415
+ We write ".A" and ".W"-appended sections. */
3416
+
3417
+ /* str --> szUtf7Buff */
3418
+ SHUnicodeToAnsiCP (CP_UTF7 , str , szUtf7Buff , _countof (szUtf7Buff ));
3419
+ szUtf7Buff [_countof (szUtf7Buff ) - 1 ] = ANSI_NULL ;
3420
+
3421
+ /* szUtf7Buff --> szWideBuff */
3422
+ SHAnsiToUnicodeCP (CP_ACP , szUtf7Buff , szWideBuff , _countof (szWideBuff ));
3423
+ szWideBuff [_countof (szWideBuff ) - 1 ] = UNICODE_NULL ;
3424
+
3425
+ /* Write ".A" version */
3426
+ lstrcpynW (szSection , appName , _countof (szSection ) - 2 );
3427
+ lstrcatW (szSection , L".A" );
3428
+ if (!WritePrivateProfileStringW (szSection , keyName , str , filename ))
3429
+ return FALSE;
3430
+
3431
+ /* Write ".W" version */
3432
+ lstrcpynW (szSection , appName , _countof (szSection ) - 2 );
3433
+ lstrcatW (szSection , L".W" );
3434
+ if (!WritePrivateProfileStringW (szSection , keyName , szWideBuff , filename ))
3435
+ return FALSE;
3436
+
3437
+ return TRUE;
3438
+ #else
3336
3439
TRACE ("(%s, %p, %s, %s)\n" , debugstr_w (appName ), keyName , debugstr_w (str ),
3337
3440
debugstr_w (filename ));
3338
3441
3339
3442
return WritePrivateProfileStringW (appName , keyName , str , filename );
3443
+ #endif
3340
3444
}
3341
3445
3342
3446
/*************************************************************************
0 commit comments