Commit d02d5029 authored by Alexandre Julliard's avatar Alexandre Julliard

winecfg: Use Unicode functions throughout.

parent a243a7af
......@@ -2,7 +2,7 @@ MODULE = winecfg.exe
APPMODE = -mwindows
IMPORTS = uuid comdlg32 comctl32 shell32 ole32 winmm shlwapi uxtheme user32 gdi32 advapi32
EXTRADLLFLAGS = -mno-cygwin
EXTRADLLFLAGS = -mno-cygwin -municode
C_SRCS = \
about.c \
......
......@@ -42,7 +42,7 @@ AboutDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
HWND hWnd;
HDC hDC;
RECT rcClient, rcRect;
char *owner, *org;
WCHAR *owner, *org;
switch (uMsg)
{
......@@ -54,14 +54,14 @@ AboutDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
owner = get_text(hDlg, IDC_ABT_OWNER);
org = get_text(hDlg, IDC_ABT_ORG);
set_reg_key(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion",
"RegisteredOwner", owner ? owner : "");
set_reg_key(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion",
"RegisteredOrganization", org ? org : "");
set_reg_key(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows NT\\CurrentVersion",
"RegisteredOwner", owner ? owner : "");
set_reg_key(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows NT\\CurrentVersion",
"RegisteredOrganization", org ? org : "");
set_reg_key(HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Windows\\CurrentVersion",
L"RegisteredOwner", owner ? owner : L"");
set_reg_key(HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Windows\\CurrentVersion",
L"RegisteredOrganization", org ? org : L"");
set_reg_key(HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Windows NT\\CurrentVersion",
L"RegisteredOwner", owner ? owner : L"");
set_reg_key(HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Windows NT\\CurrentVersion",
L"RegisteredOrganization", org ? org : L"");
apply();
HeapFree(GetProcessHeap(), 0, owner);
......@@ -80,13 +80,13 @@ AboutDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
hDC = GetDC(hDlg);
/* read owner and organization info from registry, load it into text box */
owner = get_reg_key(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows NT\\CurrentVersion",
"RegisteredOwner", "");
org = get_reg_key(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows NT\\CurrentVersion",
"RegisteredOrganization", "");
owner = get_reg_key(HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Windows NT\\CurrentVersion",
L"RegisteredOwner", L"");
org = get_reg_key(HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Windows NT\\CurrentVersion",
L"RegisteredOrganization", L"");
SetDlgItemTextA(hDlg, IDC_ABT_OWNER, owner);
SetDlgItemTextA(hDlg, IDC_ABT_ORG, org);
SetDlgItemTextW(hDlg, IDC_ABT_OWNER, owner);
SetDlgItemTextW(hDlg, IDC_ABT_ORG, org);
SendMessageW(GetParent(hDlg), PSM_UNCHANGED, 0, 0);
......@@ -110,7 +110,7 @@ AboutDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
0, 0, 0, 0, FALSE, 0, 0, 0, 0, 0, 0, 0, L"Tahoma" );
SendDlgItemMessageW(hDlg, IDC_ABT_TITLE_TEXT, WM_SETFONT, (WPARAM)titleFont, TRUE);
wine_get_version = (void *)GetProcAddress( GetModuleHandleA("ntdll.dll"), "wine_get_version" );
wine_get_version = (void *)GetProcAddress( GetModuleHandleW(L"ntdll.dll"), "wine_get_version" );
if (wine_get_version) SetDlgItemTextA(hDlg, IDC_ABT_PANEL_TEXT, wine_get_version());
ReleaseDC(hDlg, hDC);
......
......@@ -237,7 +237,7 @@ static void initAudioDlg (HWND hDlg)
PropVariantInit(&pv);
if(get_driver_name(devenum, &pv) && pv.pwszVal[0] != '\0'){
have_driver = TRUE;
wnsprintfW(display_str, ARRAY_SIZE(display_str), format_str, pv.pwszVal);
swprintf(display_str, ARRAY_SIZE(display_str), format_str, pv.pwszVal);
lstrcatW(g_drv_keyW, pv.pwszVal);
}
PropVariantClear(&pv);
......@@ -291,10 +291,10 @@ static void initAudioDlg (HWND hDlg)
if(have_driver){
WCHAR *reg_out_dev, *reg_vout_dev, *reg_in_dev, *reg_vin_dev;
reg_out_dev = get_reg_keyW(HKEY_CURRENT_USER, g_drv_keyW, L"DefaultOutput", NULL);
reg_vout_dev = get_reg_keyW(HKEY_CURRENT_USER, g_drv_keyW, L"DefaultVoiceOutput", NULL);
reg_in_dev = get_reg_keyW(HKEY_CURRENT_USER, g_drv_keyW, L"DefaultInput", NULL);
reg_vin_dev = get_reg_keyW(HKEY_CURRENT_USER, g_drv_keyW, L"DefaultVoiceInput", NULL);
reg_out_dev = get_reg_key(HKEY_CURRENT_USER, g_drv_keyW, L"DefaultOutput", NULL);
reg_vout_dev = get_reg_key(HKEY_CURRENT_USER, g_drv_keyW, L"DefaultVoiceOutput", NULL);
reg_in_dev = get_reg_key(HKEY_CURRENT_USER, g_drv_keyW, L"DefaultInput", NULL);
reg_vin_dev = get_reg_key(HKEY_CURRENT_USER, g_drv_keyW, L"DefaultVoiceInput", NULL);
for(i = 0; i < num_render_devs; ++i){
LVITEMW lvitem;
......@@ -364,7 +364,7 @@ static void initAudioDlg (HWND hDlg)
HeapFree(GetProcessHeap(), 0, reg_in_dev);
HeapFree(GetProcessHeap(), 0, reg_vin_dev);
}else
wnsprintfW(display_str, ARRAY_SIZE(display_str), format_str, disabled_str);
swprintf(display_str, ARRAY_SIZE(display_str), format_str, disabled_str);
SetDlgItemTextW(hDlg, IDC_AUDIO_DRIVER, display_str);
}
......@@ -380,9 +380,9 @@ static void set_reg_device(HWND hDlg, int dlgitem, const WCHAR *key_name)
CB_GETITEMDATA, idx, 0);
if(!info || info == (void*)CB_ERR)
set_reg_keyW(HKEY_CURRENT_USER, g_drv_keyW, key_name, NULL);
set_reg_key(HKEY_CURRENT_USER, g_drv_keyW, key_name, NULL);
else
set_reg_keyW(HKEY_CURRENT_USER, g_drv_keyW, key_name, info->id);
set_reg_key(HKEY_CURRENT_USER, g_drv_keyW, key_name, info->id);
}
static void test_sound(void)
......
......@@ -130,25 +130,25 @@ void delete_drive(struct drive *d)
static DWORD get_drive_type( char letter )
{
HKEY hKey;
char driveValue[4];
WCHAR driveValue[4];
DWORD ret = DRIVE_UNKNOWN;
sprintf(driveValue, "%c:", letter);
swprintf(driveValue, 4, L"%c:", letter);
if (RegOpenKeyA(HKEY_LOCAL_MACHINE, "Software\\Wine\\Drives", &hKey) != ERROR_SUCCESS)
if (RegOpenKeyW(HKEY_LOCAL_MACHINE, L"Software\\Wine\\Drives", &hKey) != ERROR_SUCCESS)
WINE_TRACE(" Unable to open Software\\Wine\\Drives\n" );
else
{
char buffer[80];
DWORD size = sizeof(buffer);
WCHAR buffer[80];
DWORD size = ARRAY_SIZE(buffer);
if (!RegQueryValueExA( hKey, driveValue, NULL, NULL, (LPBYTE)buffer, &size ))
if (!RegQueryValueExW( hKey, driveValue, NULL, NULL, (LPBYTE)buffer, &size ))
{
WINE_TRACE("Got type '%s' for %s\n", buffer, driveValue );
if (!lstrcmpiA( buffer, "hd" )) ret = DRIVE_FIXED;
else if (!lstrcmpiA( buffer, "network" )) ret = DRIVE_REMOTE;
else if (!lstrcmpiA( buffer, "floppy" )) ret = DRIVE_REMOVABLE;
else if (!lstrcmpiA( buffer, "cdrom" )) ret = DRIVE_CDROM;
WINE_TRACE("Got type %s for %s\n", debugstr_w(buffer), debugstr_w(driveValue) );
if (!wcsicmp( buffer, L"hd" )) ret = DRIVE_FIXED;
else if (!wcsicmp( buffer, L"network" )) ret = DRIVE_REMOTE;
else if (!wcsicmp( buffer, L"floppy" )) ret = DRIVE_REMOVABLE;
else if (!wcsicmp( buffer, L"cdrom" )) ret = DRIVE_CDROM;
}
RegCloseKey(hKey);
}
......@@ -197,49 +197,6 @@ static void set_drive_serial( WCHAR letter, DWORD serial )
}
}
#if 0
/* currently unused, but if users have this burning desire to be able to rename drives,
we can put it back in.
*/
BOOL copyDrive(struct drive *pSrc, struct drive *pDst)
{
if(pDst->in_use)
{
WINE_TRACE("pDst already in use\n");
return FALSE;
}
if(!pSrc->unixpath) WINE_TRACE("!pSrc->unixpath\n");
if(!pSrc->label) WINE_TRACE("!pSrc->label\n");
if(!pSrc->serial) WINE_TRACE("!pSrc->serial\n");
pDst->unixpath = strdupA(pSrc->unixpath);
pDst->label = strdupA(pSrc->label);
pDst->serial = strdupA(pSrc->serial);
pDst->type = pSrc->type;
pDst->in_use = TRUE;
return TRUE;
}
BOOL moveDrive(struct drive *pSrc, struct drive *pDst)
{
WINE_TRACE("pSrc->letter == %c, pDst->letter == %c\n", pSrc->letter, pDst->letter);
if(!copyDrive(pSrc, pDst))
{
WINE_TRACE("copyDrive failed\n");
return FALSE;
}
delete_drive(pSrc);
return TRUE;
}
#endif
static HANDLE open_mountmgr(void)
{
HANDLE ret;
......
......@@ -257,9 +257,9 @@ static int fill_drives_list(HWND dialog)
static void on_options_click(HWND dialog)
{
if (IsDlgButtonChecked(dialog, IDC_SHOW_DOT_FILES) == BST_CHECKED)
set_reg_key(config_key, "", "ShowDotFiles", "Y");
set_reg_key(config_key, L"", L"ShowDotFiles", L"Y");
else
set_reg_key(config_key, "", "ShowDotFiles", "N");
set_reg_key(config_key, L"", L"ShowDotFiles", L"N");
SendMessageW(GetParent(dialog), PSM_CHANGED, 0, 0);
}
......@@ -267,8 +267,8 @@ static void on_options_click(HWND dialog)
static INT_PTR CALLBACK drivechoose_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
static int i, sel;
char c;
char drive[] = "X:";
WCHAR c;
WCHAR drive[] = L"X:";
switch(uMsg)
{
......@@ -278,10 +278,10 @@ static INT_PTR CALLBACK drivechoose_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wPar
for( c = 'A'; c<= 'Z'; c++){
drive[0] = c;
if(!( mask & (1 << (c - 'A'))))
SendDlgItemMessageA( hwndDlg, IDC_DRIVESA2Z, CB_ADDSTRING, 0, (LPARAM) drive);
SendDlgItemMessageW( hwndDlg, IDC_DRIVESA2Z, CB_ADDSTRING, 0, (LPARAM) drive);
}
drive[0] = lParam;
SendDlgItemMessageA( hwndDlg, IDC_DRIVESA2Z, CB_SELECTSTRING, 0, (LPARAM) drive);
SendDlgItemMessageW( hwndDlg, IDC_DRIVESA2Z, CB_SELECTSTRING, 0, (LPARAM) drive);
return TRUE;
}
case WM_COMMAND:
......@@ -289,9 +289,9 @@ static INT_PTR CALLBACK drivechoose_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wPar
switch (LOWORD(wParam))
{
case IDOK:
i = SendDlgItemMessageA( hwndDlg, IDC_DRIVESA2Z, CB_GETCURSEL, 0, 0);
i = SendDlgItemMessageW( hwndDlg, IDC_DRIVESA2Z, CB_GETCURSEL, 0, 0);
if( i != CB_ERR){
SendDlgItemMessageA( hwndDlg, IDC_DRIVESA2Z, CB_GETLBTEXT, i, (LPARAM) drive);
SendDlgItemMessageW( hwndDlg, IDC_DRIVESA2Z, CB_GETLBTEXT, i, (LPARAM) drive);
sel = drive[0];
} else
sel = -1;
......@@ -488,7 +488,7 @@ static void on_edit_changed(HWND dialog, WORD id)
{
case IDC_EDIT_LABEL:
{
WCHAR *label = get_textW(dialog, id);
WCHAR *label = get_text(dialog, id);
HeapFree(GetProcessHeap(), 0, current_drive->label);
current_drive->label = label;
current_drive->modified = TRUE;
......@@ -506,7 +506,7 @@ static void on_edit_changed(HWND dialog, WORD id)
char *path;
int lenW;
wpath = get_textW(dialog, id);
wpath = get_text(dialog, id);
if( (lenW = WideCharToMultiByte(CP_UNIXCP, 0, wpath, -1, NULL, 0, NULL, NULL)) )
{
path = HeapAlloc(GetProcessHeap(), 0, lenW);
......@@ -535,10 +535,10 @@ static void on_edit_changed(HWND dialog, WORD id)
case IDC_EDIT_SERIAL:
{
char *serial;
WCHAR *serial;
serial = get_text(dialog, id);
current_drive->serial = serial ? strtoul( serial, NULL, 16 ) : 0;
current_drive->serial = serial ? wcstoul( serial, NULL, 16 ) : 0;
HeapFree(GetProcessHeap(), 0, serial);
current_drive->modified = TRUE;
......@@ -551,7 +551,7 @@ static void on_edit_changed(HWND dialog, WORD id)
case IDC_EDIT_DEVICE:
{
char *device = get_text(dialog, id);
WCHAR *device = get_text(dialog, id);
/* TODO: handle device if/when it makes sense to do so.... */
HeapFree(GetProcessHeap(), 0, device);
break;
......@@ -646,7 +646,7 @@ static void init_listview_columns(HWND dialog)
static void load_drive_options(HWND dialog)
{
if (!strcmp(get_reg_key(config_key, "", "ShowDotFiles", "N"), "Y"))
if (!wcscmp(get_reg_key(config_key, L"", L"ShowDotFiles", L"N"), L"Y"))
CheckDlgButton(dialog, IDC_SHOW_DOT_FILES, BST_CHECKED);
}
......
......@@ -181,7 +181,7 @@ doPropertySheet (HINSTANCE hInstance, HWND hOwner)
* program execution.
*/
static int
ProcessCmdLine(LPSTR lpCmdLine)
ProcessCmdLine(LPWSTR lpCmdLine)
{
if (!(lpCmdLine[0] == '/' || lpCmdLine[0] == '-'))
{
......@@ -189,7 +189,7 @@ ProcessCmdLine(LPSTR lpCmdLine)
}
if (lpCmdLine[1] == 'V' || lpCmdLine[1] == 'v')
{
if (lstrlenA(lpCmdLine) > 4)
if (wcslen(lpCmdLine) > 4)
return set_winver_from_string(&lpCmdLine[3]) ? 0 : 1;
print_current_winver();
......@@ -223,7 +223,7 @@ ProcessCmdLine(LPSTR lpCmdLine)
* Returns : Program exit code
*/
int WINAPI
WinMain (HINSTANCE hInstance, HINSTANCE hPrev, LPSTR szCmdLine, int nShow)
wWinMain (HINSTANCE hInstance, HINSTANCE hPrev, LPWSTR cmdline, int nShow)
{
BOOL is_wow64;
int cmd_ret;
......@@ -256,7 +256,7 @@ WinMain (HINSTANCE hInstance, HINSTANCE hPrev, LPSTR szCmdLine, int nShow)
ExitProcess(1);
}
cmd_ret = ProcessCmdLine(szCmdLine);
cmd_ret = ProcessCmdLine(cmdline);
if (cmd_ret >= 0) return cmd_ret;
/*
......
......@@ -62,7 +62,7 @@ void set_window_title(HWND dialog)
{
WCHAR apptitle[256];
LoadStringW(GetModuleHandleW(NULL), IDS_WINECFG_TITLE_APP, apptitle, ARRAY_SIZE(apptitle));
wsprintfW (newtitle, apptitle, current_app);
swprintf(newtitle, ARRAY_SIZE(newtitle), apptitle, current_app);
}
else
{
......@@ -245,7 +245,7 @@ static void free_setting(struct setting *setting)
* If already in the list, the contents as given there will be
* returned. You are expected to HeapFree the result.
*/
WCHAR *get_reg_keyW(HKEY root, const WCHAR *path, const WCHAR *name, const WCHAR *def)
WCHAR *get_reg_key(HKEY root, const WCHAR *path, const WCHAR *name, const WCHAR *def)
{
struct list *cursor;
struct setting *s;
......@@ -278,43 +278,6 @@ WCHAR *get_reg_keyW(HKEY root, const WCHAR *path, const WCHAR *name, const WCHAR
return val;
}
char *get_reg_key(HKEY root, const char *path, const char *name, const char *def)
{
WCHAR *wpath, *wname, *wdef = NULL, *wRet = NULL;
char *szRet = NULL;
int len;
WINE_TRACE("path=%s, name=%s, def=%s\n", path, name, def);
wpath = HeapAlloc(GetProcessHeap(), 0, (strlen(path)+1)*sizeof(WCHAR));
wname = HeapAlloc(GetProcessHeap(), 0, (strlen(name)+1)*sizeof(WCHAR));
MultiByteToWideChar(CP_ACP, 0, path, -1, wpath, strlen(path)+1);
MultiByteToWideChar(CP_ACP, 0, name, -1, wname, strlen(name)+1);
if (def)
{
wdef = HeapAlloc(GetProcessHeap(), 0, (strlen(def)+1)*sizeof(WCHAR));
MultiByteToWideChar(CP_ACP, 0, def, -1, wdef, strlen(def)+1);
}
wRet = get_reg_keyW(root, wpath, wname, wdef);
len = WideCharToMultiByte(CP_ACP, 0, wRet, -1, NULL, 0, NULL, NULL);
if (len)
{
szRet = HeapAlloc(GetProcessHeap(), 0, len);
WideCharToMultiByte(CP_ACP, 0, wRet, -1, szRet, len, NULL, NULL);
}
HeapFree(GetProcessHeap(), 0, wpath);
HeapFree(GetProcessHeap(), 0, wname);
HeapFree(GetProcessHeap(), 0, wdef);
HeapFree(GetProcessHeap(), 0, wRet);
return szRet;
}
/**
* Used to set a registry key.
*
......@@ -402,54 +365,12 @@ static void set_reg_key_ex(HKEY root, const WCHAR *path, const WCHAR *name, cons
list_add_tail(&settings, &s->entry);
}
void set_reg_key(HKEY root, const char *path, const char *name, const char *value)
{
WCHAR *wpath, *wname = NULL, *wvalue = NULL;
wpath = HeapAlloc(GetProcessHeap(), 0, (strlen(path)+1)*sizeof(WCHAR));
MultiByteToWideChar(CP_ACP, 0, path, -1, wpath, strlen(path)+1);
if (name)
{
wname = HeapAlloc(GetProcessHeap(), 0, (strlen(name)+1)*sizeof(WCHAR));
MultiByteToWideChar(CP_ACP, 0, name, -1, wname, strlen(name)+1);
}
if (value)
{
wvalue = HeapAlloc(GetProcessHeap(), 0, (strlen(value)+1)*sizeof(WCHAR));
MultiByteToWideChar(CP_ACP, 0, value, -1, wvalue, strlen(value)+1);
}
set_reg_key_ex(root, wpath, wname, wvalue, REG_SZ);
HeapFree(GetProcessHeap(), 0, wpath);
HeapFree(GetProcessHeap(), 0, wname);
HeapFree(GetProcessHeap(), 0, wvalue);
}
void set_reg_key_dword(HKEY root, const char *path, const char *name, DWORD value)
{
WCHAR *wpath, *wname;
wpath = HeapAlloc(GetProcessHeap(), 0, (strlen(path)+1)*sizeof(WCHAR));
wname = HeapAlloc(GetProcessHeap(), 0, (strlen(name)+1)*sizeof(WCHAR));
MultiByteToWideChar(CP_ACP, 0, path, -1, wpath, strlen(path)+1);
MultiByteToWideChar(CP_ACP, 0, name, -1, wname, strlen(name)+1);
set_reg_key_ex(root, wpath, wname, &value, REG_DWORD);
HeapFree(GetProcessHeap(), 0, wpath);
HeapFree(GetProcessHeap(), 0, wname);
}
void set_reg_keyW(HKEY root, const WCHAR *path, const WCHAR *name, const WCHAR *value)
void set_reg_key(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)
void set_reg_key_dword(HKEY root, const WCHAR *path, const WCHAR *name, DWORD value)
{
set_reg_key_ex(root, path, name, &value, REG_DWORD);
}
......@@ -461,7 +382,7 @@ void set_reg_key_dwordW(HKEY root, const WCHAR *path, const WCHAR *name, DWORD v
* you are expected to HeapFree each element of the array, which is null
* terminated, as well as the array itself.
*/
static WCHAR **enumerate_valuesW(HKEY root, WCHAR *path)
WCHAR **enumerate_values(HKEY root, const WCHAR *path)
{
HKEY key;
DWORD res, i = 0, valueslen = 0;
......@@ -563,58 +484,16 @@ static WCHAR **enumerate_valuesW(HKEY root, WCHAR *path)
return values;
}
char **enumerate_values(HKEY root, char *path)
{
WCHAR *wpath;
WCHAR **wret;
char **ret=NULL;
int i=0, len=0, size;
wpath = HeapAlloc(GetProcessHeap(), 0, (strlen(path)+1)*sizeof(WCHAR));
MultiByteToWideChar(CP_ACP, 0, path, -1, wpath, strlen(path)+1);
wret = enumerate_valuesW(root, wpath);
if (wret)
{
for(len=0; wret[len]; len++);
ret = HeapAlloc(GetProcessHeap(), 0, (len+1)*sizeof(char*));
/* convert WCHAR ** to char ** and HeapFree each WCHAR * element on our way */
for (i=0; i<len; i++)
{
size = WideCharToMultiByte(CP_ACP, 0, wret[i], -1, NULL, 0, NULL, NULL);
if(size)
{
ret[i] = HeapAlloc(GetProcessHeap(), 0, size);
WideCharToMultiByte(CP_ACP, 0, wret[i], -1, ret[i], size, NULL, NULL);
HeapFree(GetProcessHeap(), 0, wret[i]);
}
}
ret[len] = NULL;
}
HeapFree(GetProcessHeap(), 0, wpath);
HeapFree(GetProcessHeap(), 0, wret);
return ret;
}
/**
* returns true if the given key/value pair exists in the registry or
* has been written to.
*/
BOOL reg_key_exists(HKEY root, const char *path, const char *name)
BOOL reg_key_exists(HKEY root, const WCHAR *path, const WCHAR *name)
{
char *val = get_reg_key(root, path, name, NULL);
if (val)
{
HeapFree(GetProcessHeap(), 0, val);
return TRUE;
}
WCHAR *val = get_reg_key(root, path, name, NULL);
return FALSE;
HeapFree(GetProcessHeap(), 0, val);
return val != NULL;
}
static void process_setting(struct setting *s)
......@@ -685,27 +564,7 @@ void apply(void)
WCHAR* current_app = NULL; /* the app we are currently editing, or NULL if editing global */
/* returns a registry key path suitable for passing to addTransaction */
char *keypath(const char *section)
{
static char *result = NULL;
HeapFree(GetProcessHeap(), 0, result);
if (current_app)
{
result = HeapAlloc(GetProcessHeap(), 0, strlen("AppDefaults\\") + lstrlenW(current_app)*2 + 2 /* \\ */ + strlen(section) + 1 /* terminator */);
wsprintfA(result, "AppDefaults\\%ls", current_app);
if (section[0]) sprintf( result + strlen(result), "\\%s", section );
}
else
{
result = strdupA(section);
}
return result;
}
WCHAR *keypathW(const WCHAR *section)
WCHAR *keypath(const WCHAR *section)
{
static WCHAR *result = NULL;
......@@ -748,7 +607,7 @@ void PRINTERROR(void)
BOOL initialize(HINSTANCE hInstance)
{
DWORD res = RegCreateKeyA(HKEY_CURRENT_USER, WINE_KEY_ROOT, &config_key);
DWORD res = RegCreateKeyW(HKEY_CURRENT_USER, WINE_KEY_ROOT, &config_key);
if (res != ERROR_SUCCESS) {
WINE_ERR("RegOpenKey failed on wine config key (%d)\n", res);
......
......@@ -51,16 +51,13 @@ extern WCHAR* current_app; /* NULL means editing global settings */
be copied, so free them too when necessary.
*/
void set_reg_keyW(HKEY root, const WCHAR *path, const WCHAR *name, const WCHAR *value);
void set_reg_key_dwordW(HKEY root, const WCHAR *path, const WCHAR *name, DWORD value);
WCHAR *get_reg_keyW(HKEY root, const WCHAR *path, const WCHAR *name, const WCHAR *def);
void set_reg_key(HKEY root, const char *path, const char *name, const char *value);
void set_reg_key_dword(HKEY root, const char *path, const char *name, DWORD value);
char *get_reg_key(HKEY root, const char *path, const char *name, const char *def);
BOOL reg_key_exists(HKEY root, const char *path, const char *name);
void set_reg_key(HKEY root, const WCHAR *path, const WCHAR *name, const WCHAR *value);
void set_reg_key_dword(HKEY root, const WCHAR *path, const WCHAR *name, DWORD value);
WCHAR *get_reg_key(HKEY root, const WCHAR *path, const WCHAR *name, const WCHAR *def);
BOOL reg_key_exists(HKEY root, const WCHAR *path, const WCHAR *name);
void apply(void);
char **enumerate_values(HKEY root, char *path);
WCHAR **enumerate_values(HKEY root, const WCHAR *path);
/* Load a string from the resources. Allocated with HeapAlloc (GetProcessHeap()) */
WCHAR* load_string (UINT id);
......@@ -70,8 +67,7 @@ WCHAR* load_string (UINT id);
no explicit free is needed of the string returned by this function
*/
char *keypath(const char *section);
WCHAR *keypathW(const WCHAR *section);
WCHAR *keypath(const WCHAR *section);
BOOL initialize(HINSTANCE hInstance);
extern HKEY config_key;
......@@ -90,7 +86,7 @@ INT_PTR CALLBACK ThemeDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
INT_PTR CALLBACK AboutDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
/* Windows version management */
BOOL set_winver_from_string(const char *version);
BOOL set_winver_from_string(const WCHAR *version);
void print_current_winver(void);
void print_windows_versions(void);
......@@ -153,20 +149,7 @@ static inline WCHAR *strdupU2W(const char *unix_str)
return unicode_str;
}
static inline char *get_text(HWND dialog, WORD id)
{
HWND item = GetDlgItem(dialog, id);
int len = GetWindowTextLengthA(item) + 1;
char *result = len ? HeapAlloc(GetProcessHeap(), 0, len) : NULL;
if (!result) return NULL;
if (GetWindowTextA(item, result, len) == 0) {
HeapFree (GetProcessHeap(), 0, result);
return NULL;
}
return result;
}
static inline WCHAR *get_textW(HWND dialog, WORD id)
static inline WCHAR *get_text(HWND dialog, WORD id)
{
HWND item = GetDlgItem(dialog, id);
int len = GetWindowTextLengthW(item) + 1;
......@@ -189,7 +172,7 @@ static inline void set_textW(HWND dialog, WORD id, const WCHAR *text)
SetWindowTextW(GetDlgItem(dialog, id), text);
}
#define WINE_KEY_ROOT "Software\\Wine"
#define WINE_KEY_ROOT L"Software\\Wine"
#define MAXBUFLEN 256
extern HMENU hPopupMenus;
......
......@@ -49,12 +49,12 @@ static BOOL updating_ui;
/* convert the x11 desktop key to the new explorer config */
static void convert_x11_desktop_key(void)
{
char *buf;
WCHAR *buf;
if (!(buf = get_reg_key(config_key, "X11 Driver", "Desktop", NULL))) return;
set_reg_key(config_key, "Explorer\\Desktops", "Default", buf);
set_reg_key(config_key, "Explorer", "Desktop", "Default");
set_reg_key(config_key, "X11 Driver", "Desktop", NULL);
if (!(buf = get_reg_key(config_key, L"X11 Driver", L"Desktop", NULL))) return;
set_reg_key(config_key, L"Explorer\\Desktops", L"Default", buf);
set_reg_key(config_key, L"Explorer", L"Desktop", L"Default");
set_reg_key(config_key, L"X11 Driver", L"Desktop", NULL);
HeapFree(GetProcessHeap(), 0, buf);
}
......@@ -66,7 +66,7 @@ static void update_gui_for_desktop_mode(HWND dialog)
WINE_TRACE("\n");
updating_ui = TRUE;
buf = get_reg_keyW(config_key, L"Explorer\\Desktops", desktop_name, NULL);
buf = get_reg_key(config_key, L"Explorer\\Desktops", desktop_name, NULL);
if (buf && (bufindex = wcschr(buf, 'x')))
{
*bufindex++ = 0;
......@@ -74,13 +74,13 @@ static void update_gui_for_desktop_mode(HWND dialog)
SetDlgItemTextW(dialog, IDC_DESKTOP_WIDTH, buf);
SetDlgItemTextW(dialog, IDC_DESKTOP_HEIGHT, bufindex);
} else {
SetDlgItemTextA(dialog, IDC_DESKTOP_WIDTH, "800");
SetDlgItemTextA(dialog, IDC_DESKTOP_HEIGHT, "600");
SetDlgItemTextW(dialog, IDC_DESKTOP_WIDTH, L"800");
SetDlgItemTextW(dialog, IDC_DESKTOP_HEIGHT, L"600");
}
HeapFree(GetProcessHeap(), 0, buf);
/* do we have desktop mode enabled? */
if (reg_key_exists(config_key, keypath("Explorer"), "Desktop"))
if (reg_key_exists(config_key, keypath(L"Explorer"), L"Desktop"))
{
CheckDlgButton(dialog, IDC_ENABLE_DESKTOP, BST_CHECKED);
enable(IDC_DESKTOP_WIDTH);
......@@ -102,18 +102,18 @@ static void update_gui_for_desktop_mode(HWND dialog)
static BOOL can_enable_desktop(void)
{
char *value;
WCHAR *value;
UINT guid_atom;
BOOL ret = FALSE;
char key[sizeof("System\\CurrentControlSet\\Control\\Video\\{}\\0000") + 40];
WCHAR key[sizeof("System\\CurrentControlSet\\Control\\Video\\{}\\0000") + 40];
guid_atom = HandleToULong(GetPropA(GetDesktopWindow(), "__wine_display_device_guid"));
strcpy( key, "System\\CurrentControlSet\\Control\\Video\\{" );
if (!GlobalGetAtomNameA(guid_atom, key + strlen(key), 40)) return ret;
strcat( key, "}\\0000" );
if ((value = get_reg_key(HKEY_LOCAL_MACHINE, key, "GraphicsDriver", NULL)))
guid_atom = HandleToULong(GetPropW(GetDesktopWindow(), L"__wine_display_device_guid"));
wcscpy( key, L"System\\CurrentControlSet\\Control\\Video\\{" );
if (!GlobalGetAtomNameW(guid_atom, key + wcslen(key), 40)) return ret;
wcscat( key, L"}\\0000" );
if ((value = get_reg_key(HKEY_LOCAL_MACHINE, key, L"GraphicsDriver", NULL)))
{
if(strcmp(value, "winemac.drv"))
if(wcscmp(value, L"winemac.drv"))
ret = TRUE;
HeapFree(GetProcessHeap(), 0, value);
}
......@@ -122,7 +122,7 @@ static BOOL can_enable_desktop(void)
static void init_dialog(HWND dialog)
{
char* buf;
WCHAR *buf;
BOOL enable_desktop;
convert_x11_desktop_key();
......@@ -139,21 +139,21 @@ static void init_dialog(HWND dialog)
SendDlgItemMessageW(dialog, IDC_DESKTOP_HEIGHT, EM_LIMITTEXT, RES_MAXLEN, 0);
}
buf = get_reg_key(config_key, keypath("X11 Driver"), "GrabFullscreen", "N");
buf = get_reg_key(config_key, keypath(L"X11 Driver"), L"GrabFullscreen", L"N");
if (IS_OPTION_TRUE(*buf))
CheckDlgButton(dialog, IDC_FULLSCREEN_GRAB, BST_CHECKED);
else
CheckDlgButton(dialog, IDC_FULLSCREEN_GRAB, BST_UNCHECKED);
HeapFree(GetProcessHeap(), 0, buf);
buf = get_reg_key(config_key, keypath("X11 Driver"), "Managed", "Y");
buf = get_reg_key(config_key, keypath(L"X11 Driver"), L"Managed", L"Y");
if (IS_OPTION_TRUE(*buf))
CheckDlgButton(dialog, IDC_ENABLE_MANAGED, BST_CHECKED);
else
CheckDlgButton(dialog, IDC_ENABLE_MANAGED, BST_UNCHECKED);
HeapFree(GetProcessHeap(), 0, buf);
buf = get_reg_key(config_key, keypath("X11 Driver"), "Decorated", "Y");
buf = get_reg_key(config_key, keypath(L"X11 Driver"), L"Decorated", L"Y");
if (IS_OPTION_TRUE(*buf))
CheckDlgButton(dialog, IDC_ENABLE_DECORATED, BST_CHECKED);
else
......@@ -174,15 +174,15 @@ static void set_from_desktop_edits(HWND dialog)
WINE_TRACE("\n");
width = get_textW(dialog, IDC_DESKTOP_WIDTH);
height = get_textW(dialog, IDC_DESKTOP_HEIGHT);
width = get_text(dialog, IDC_DESKTOP_WIDTH);
height = get_text(dialog, IDC_DESKTOP_HEIGHT);
if (width && width[0]) w = max( 640, wcstol(width, NULL, 10) );
if (height && height[0]) h = max( 480, wcstol(height, NULL, 10) );
swprintf( buffer, ARRAY_SIZE(buffer), L"%ux%u", w, h );
set_reg_keyW(config_key, L"Explorer\\Desktops", desktop_name, buffer);
set_reg_keyW(config_key, keypathW(L"Explorer"), L"Desktop", desktop_name);
set_reg_key(config_key, L"Explorer\\Desktops", desktop_name, buffer);
set_reg_key(config_key, keypath(L"Explorer"), L"Desktop", desktop_name);
HeapFree(GetProcessHeap(), 0, width);
HeapFree(GetProcessHeap(), 0, height);
......@@ -194,7 +194,7 @@ static void on_enable_desktop_clicked(HWND dialog) {
if (IsDlgButtonChecked(dialog, IDC_ENABLE_DESKTOP) == BST_CHECKED) {
set_from_desktop_edits(dialog);
} else {
set_reg_key(config_key, keypath("Explorer"), "Desktop", NULL);
set_reg_key(config_key, keypath(L"Explorer"), L"Desktop", NULL);
}
update_gui_for_desktop_mode(dialog);
......@@ -204,9 +204,9 @@ static void on_enable_managed_clicked(HWND dialog) {
WINE_TRACE("\n");
if (IsDlgButtonChecked(dialog, IDC_ENABLE_MANAGED) == BST_CHECKED) {
set_reg_key(config_key, keypath("X11 Driver"), "Managed", "Y");
set_reg_key(config_key, keypath(L"X11 Driver"), L"Managed", L"Y");
} else {
set_reg_key(config_key, keypath("X11 Driver"), "Managed", "N");
set_reg_key(config_key, keypath(L"X11 Driver"), L"Managed", L"N");
}
}
......@@ -214,25 +214,25 @@ static void on_enable_decorated_clicked(HWND dialog) {
WINE_TRACE("\n");
if (IsDlgButtonChecked(dialog, IDC_ENABLE_DECORATED) == BST_CHECKED) {
set_reg_key(config_key, keypath("X11 Driver"), "Decorated", "Y");
set_reg_key(config_key, keypath(L"X11 Driver"), L"Decorated", L"Y");
} else {
set_reg_key(config_key, keypath("X11 Driver"), "Decorated", "N");
set_reg_key(config_key, keypath(L"X11 Driver"), L"Decorated", L"N");
}
}
static void on_fullscreen_grab_clicked(HWND dialog)
{
if (IsDlgButtonChecked(dialog, IDC_FULLSCREEN_GRAB) == BST_CHECKED)
set_reg_key(config_key, keypath("X11 Driver"), "GrabFullscreen", "Y");
set_reg_key(config_key, keypath(L"X11 Driver"), L"GrabFullscreen", L"Y");
else
set_reg_key(config_key, keypath("X11 Driver"), "GrabFullscreen", "N");
set_reg_key(config_key, keypath(L"X11 Driver"), L"GrabFullscreen", L"N");
}
static INT read_logpixels_reg(void)
{
DWORD dwLogPixels;
WCHAR *buf = get_reg_keyW(HKEY_CURRENT_USER, L"Control Panel\\Desktop", L"LogPixels", NULL);
if (!buf) buf = get_reg_keyW(HKEY_CURRENT_CONFIG, L"Software\\Fonts", L"LogPixels", NULL);
WCHAR *buf = get_reg_key(HKEY_CURRENT_USER, L"Control Panel\\Desktop", L"LogPixels", NULL);
if (!buf) buf = get_reg_key(HKEY_CURRENT_CONFIG, L"Software\\Fonts", L"LogPixels", NULL);
dwLogPixels = buf ? *buf : DEFDPI;
HeapFree(GetProcessHeap(), 0, buf);
return dwLogPixels;
......@@ -302,7 +302,7 @@ static void update_dpi_trackbar_from_edit(HWND hDlg, BOOL fix)
if (dpi >= MINDPI && dpi <= MAXDPI)
{
SendDlgItemMessageW(hDlg, IDC_RES_TRACKBAR, TBM_SETPOS, TRUE, get_trackbar_pos(dpi));
set_reg_key_dwordW(HKEY_CURRENT_USER, L"Control Panel\\Desktop", L"LogPixels", dpi);
set_reg_key_dword(HKEY_CURRENT_USER, L"Control Panel\\Desktop", L"LogPixels", dpi);
}
updating_ui = FALSE;
......@@ -422,7 +422,7 @@ GraphDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
int i = SendMessageW(GetDlgItem(hDlg, IDC_RES_TRACKBAR), TBM_GETPOS, 0, 0);
SetDlgItemInt(hDlg, IDC_RES_DPIEDIT, dpi_values[i], TRUE);
update_font_preview(hDlg);
set_reg_key_dwordW(HKEY_CURRENT_USER, L"Control Panel\\Desktop", L"LogPixels", dpi_values[i]);
set_reg_key_dword(HKEY_CURRENT_USER, L"Control Panel\\Desktop", L"LogPixels", dpi_values[i]);
break;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment