From ad5876734d69c8ac57e2d6ec01ec4074b47b1635 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Fri, 25 Apr 2008 14:36:25 +0200 Subject: [PATCH] winecfg: Add a couple of Unicode helper functions. --- programs/winecfg/winecfg.c | 33 +++++++++++++++++++++++++++++++++ programs/winecfg/winecfg.h | 3 ++- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/programs/winecfg/winecfg.c b/programs/winecfg/winecfg.c index b21599d425f..3fdc7968377 100644 --- a/programs/winecfg/winecfg.c +++ b/programs/winecfg/winecfg.c @@ -461,6 +461,11 @@ void set_reg_key_dword(HKEY root, const char *path, const char *name, DWORD valu HeapFree(GetProcessHeap(), 0, wname); } +void set_reg_keyW(HKEY root, const WCHAR *path, const WCHAR *name, const WCHAR *value) +{ + set_reg_key_ex(root, path, name, value, REG_SZ); +} + void set_reg_key_dwordW(HKEY root, const WCHAR *path, const WCHAR *name, DWORD value) { set_reg_key_ex(root, path, name, &value, REG_DWORD); @@ -684,6 +689,34 @@ char *keypath(const char *section) return result; } +WCHAR *keypathW(const WCHAR *section) +{ + static const WCHAR appdefaultsW[] = {'A','p','p','D','e','f','a','u','l','t','s','\\',0}; + static WCHAR *result = NULL; + + HeapFree(GetProcessHeap(), 0, result); + + if (current_app) + { + DWORD len = sizeof(appdefaultsW) + (lstrlenW(current_app) + lstrlenW(section) + 1) * sizeof(WCHAR); + result = HeapAlloc(GetProcessHeap(), 0, len ); + lstrcpyW( result, appdefaultsW ); + lstrcatW( result, current_app ); + if (section[0]) + { + len = lstrlenW(result); + result[len++] = '\\'; + lstrcpyW( result + len, section ); + } + } + else + { + result = strdupW(section); + } + + return result; +} + void PRINTERROR(void) { LPSTR msg; diff --git a/programs/winecfg/winecfg.h b/programs/winecfg/winecfg.h index b0e2d39e228..7b0006a4be7 100644 --- a/programs/winecfg/winecfg.h +++ b/programs/winecfg/winecfg.h @@ -71,7 +71,8 @@ WCHAR* load_string (UINT id); no explicit free is needed of the string returned by this function */ -char *keypath(const char *section); +char *keypath(const char *section); +WCHAR *keypathW(const WCHAR *section); int initialize(HINSTANCE hInstance); extern HKEY config_key;