2003-03-31 21:41:55 +02:00
|
|
|
/*
|
|
|
|
* WineCfg configuration management
|
|
|
|
*
|
|
|
|
* Copyright 2002 Jaco Greeff
|
|
|
|
* Copyright 2003 Dimitrie O. Paun
|
2004-09-28 05:16:43 +02:00
|
|
|
* Copyright 2003-2004 Mike Hearn
|
2003-03-31 21:41:55 +02:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2003-03-31 21:41:55 +02:00
|
|
|
*
|
2004-11-23 14:50:23 +01:00
|
|
|
* TODO:
|
|
|
|
* - Use unicode
|
|
|
|
* - Icons in listviews/icons
|
|
|
|
* - Better add app dialog, scan c: for EXE files and add to list in background
|
|
|
|
* - Use [GNOME] HIG style groupboxes rather than win32 style (looks nicer, imho)
|
|
|
|
*
|
2003-03-31 21:41:55 +02:00
|
|
|
*/
|
|
|
|
|
2006-01-19 11:55:01 +01:00
|
|
|
#define WIN32_LEAN_AND_MEAN
|
|
|
|
|
2003-09-08 20:58:07 +02:00
|
|
|
#include <assert.h>
|
2003-03-31 21:41:55 +02:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <limits.h>
|
|
|
|
#include <windows.h>
|
2003-04-27 02:33:07 +02:00
|
|
|
#include <winreg.h>
|
2010-12-15 22:30:18 +01:00
|
|
|
#include <wine/unicode.h>
|
2003-04-27 02:33:07 +02:00
|
|
|
#include <wine/debug.h>
|
2004-09-28 05:55:16 +02:00
|
|
|
#include <wine/list.h>
|
2003-04-27 02:33:07 +02:00
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(winecfg);
|
2003-03-31 21:41:55 +02:00
|
|
|
|
|
|
|
#include "winecfg.h"
|
2005-12-17 12:30:06 +01:00
|
|
|
#include "resource.h"
|
2003-03-31 21:41:55 +02:00
|
|
|
|
2013-10-09 00:06:18 +02:00
|
|
|
static const BOOL is_win64 = (sizeof(void *) > sizeof(int));
|
2010-12-15 22:30:18 +01:00
|
|
|
|
2004-09-28 05:55:16 +02:00
|
|
|
HKEY config_key = NULL;
|
2005-12-17 12:30:06 +01:00
|
|
|
HMENU hPopupMenus = 0;
|
2003-03-31 21:41:55 +02:00
|
|
|
|
2004-09-28 05:55:16 +02:00
|
|
|
|
|
|
|
/* this is called from the WM_SHOWWINDOW handlers of each tab page.
|
|
|
|
*
|
|
|
|
* it's a nasty hack, necessary because the property sheet insists on resetting the window title
|
|
|
|
* to the title of the tab, which is utterly useless. dropping the property sheet is on the todo list.
|
|
|
|
*/
|
|
|
|
void set_window_title(HWND dialog)
|
|
|
|
{
|
2006-08-16 18:30:48 +02:00
|
|
|
WCHAR newtitle[256];
|
2004-09-28 05:55:16 +02:00
|
|
|
|
|
|
|
/* update the window title */
|
2004-11-23 14:50:23 +01:00
|
|
|
if (current_app)
|
2004-09-28 05:55:16 +02:00
|
|
|
{
|
2006-08-16 18:30:48 +02:00
|
|
|
WCHAR apptitle[256];
|
2012-01-20 12:42:33 +01:00
|
|
|
LoadStringW (GetModuleHandleW(NULL), IDS_WINECFG_TITLE_APP, apptitle,
|
2006-08-16 18:30:48 +02:00
|
|
|
sizeof(apptitle)/sizeof(apptitle[0]));
|
|
|
|
wsprintfW (newtitle, apptitle, current_app);
|
2003-09-08 20:58:07 +02:00
|
|
|
}
|
2004-09-28 05:55:16 +02:00
|
|
|
else
|
|
|
|
{
|
2012-01-20 12:42:33 +01:00
|
|
|
LoadStringW (GetModuleHandleW(NULL), IDS_WINECFG_TITLE, newtitle,
|
2006-08-16 18:30:48 +02:00
|
|
|
sizeof(newtitle)/sizeof(newtitle[0]));
|
2004-09-28 05:55:16 +02:00
|
|
|
}
|
|
|
|
|
2006-08-16 18:30:48 +02:00
|
|
|
WINE_TRACE("setting title to %s\n", wine_dbgstr_w (newtitle));
|
|
|
|
SendMessageW (GetParent(dialog), PSM_SETTITLEW, 0, (LPARAM) newtitle);
|
2003-03-31 21:41:55 +02:00
|
|
|
}
|
|
|
|
|
2003-09-08 20:58:07 +02:00
|
|
|
|
2006-08-16 06:22:54 +02:00
|
|
|
WCHAR* load_string (UINT id)
|
|
|
|
{
|
2006-08-23 12:01:35 +02:00
|
|
|
WCHAR buf[1024];
|
2006-08-16 06:22:54 +02:00
|
|
|
int len;
|
|
|
|
WCHAR* newStr;
|
|
|
|
|
2012-01-20 12:42:33 +01:00
|
|
|
LoadStringW (GetModuleHandleW(NULL), id, buf, sizeof(buf)/sizeof(buf[0]));
|
2006-08-16 06:22:54 +02:00
|
|
|
|
|
|
|
len = lstrlenW (buf);
|
|
|
|
newStr = HeapAlloc (GetProcessHeap(), 0, (len + 1) * sizeof (WCHAR));
|
|
|
|
memcpy (newStr, buf, len * sizeof (WCHAR));
|
|
|
|
newStr[len] = 0;
|
|
|
|
return newStr;
|
|
|
|
}
|
|
|
|
|
2004-09-28 05:55:16 +02:00
|
|
|
/**
|
2004-11-30 22:03:36 +01:00
|
|
|
* get_config_key: Retrieves a configuration value from the registry
|
2003-08-30 02:27:08 +02:00
|
|
|
*
|
2004-09-28 05:55:16 +02:00
|
|
|
* char *subkey : the name of the config section
|
|
|
|
* char *name : the name of the config value
|
|
|
|
* char *default : if the key isn't found, return this value instead
|
2003-08-30 02:27:08 +02:00
|
|
|
*
|
2004-09-28 05:55:16 +02:00
|
|
|
* Returns a buffer holding the value if successful, NULL if
|
|
|
|
* not. Caller is responsible for releasing the result.
|
2003-08-30 02:27:08 +02:00
|
|
|
*
|
2003-04-27 02:33:07 +02:00
|
|
|
*/
|
2007-08-03 01:33:24 +02:00
|
|
|
static WCHAR *get_config_key (HKEY root, const WCHAR *subkey, const WCHAR *name, const WCHAR *def)
|
2003-04-27 02:33:07 +02:00
|
|
|
{
|
2007-08-03 01:33:24 +02:00
|
|
|
LPWSTR buffer = NULL;
|
2004-09-28 05:55:16 +02:00
|
|
|
DWORD len;
|
2003-08-30 02:27:08 +02:00
|
|
|
HKEY hSubKey = NULL;
|
2003-09-08 20:58:07 +02:00
|
|
|
DWORD res;
|
2003-04-27 02:33:07 +02:00
|
|
|
|
2007-08-03 01:33:24 +02:00
|
|
|
WINE_TRACE("subkey=%s, name=%s, def=%s\n", wine_dbgstr_w(subkey),
|
|
|
|
wine_dbgstr_w(name), wine_dbgstr_w(def));
|
2003-09-08 20:58:07 +02:00
|
|
|
|
2011-03-11 09:04:37 +01:00
|
|
|
res = RegOpenKeyExW(root, subkey, 0, MAXIMUM_ALLOWED, &hSubKey);
|
2004-09-28 05:55:16 +02:00
|
|
|
if (res != ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
if (res == ERROR_FILE_NOT_FOUND)
|
2003-04-27 02:33:07 +02:00
|
|
|
{
|
2003-08-30 02:27:08 +02:00
|
|
|
WINE_TRACE("Section key not present - using default\n");
|
2007-08-03 01:33:24 +02:00
|
|
|
return def ? strdupW(def) : NULL;
|
2003-04-27 02:33:07 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-10-02 23:19:18 +02:00
|
|
|
WINE_ERR("RegOpenKey failed on wine config key (res=%d)\n", res);
|
2003-04-27 02:33:07 +02:00
|
|
|
}
|
|
|
|
goto end;
|
|
|
|
}
|
2003-09-30 02:27:55 +02:00
|
|
|
|
2007-08-03 01:33:24 +02:00
|
|
|
res = RegQueryValueExW(hSubKey, name, NULL, NULL, NULL, &len);
|
2004-09-28 05:55:16 +02:00
|
|
|
if (res == ERROR_FILE_NOT_FOUND)
|
|
|
|
{
|
2003-04-27 02:33:07 +02:00
|
|
|
WINE_TRACE("Value not present - using default\n");
|
2007-08-03 01:33:24 +02:00
|
|
|
buffer = def ? strdupW(def) : NULL;
|
2003-09-08 20:58:07 +02:00
|
|
|
goto end;
|
2004-09-28 05:55:16 +02:00
|
|
|
} else if (res != ERROR_SUCCESS)
|
2003-04-27 02:33:07 +02:00
|
|
|
{
|
2006-10-02 23:19:18 +02:00
|
|
|
WINE_ERR("Couldn't query value's length (res=%d)\n", res);
|
2003-04-27 02:33:07 +02:00
|
|
|
goto end;
|
|
|
|
}
|
2004-09-28 05:55:16 +02:00
|
|
|
|
2007-08-03 01:33:24 +02:00
|
|
|
buffer = HeapAlloc(GetProcessHeap(), 0, len + sizeof(WCHAR));
|
2004-09-28 05:55:16 +02:00
|
|
|
|
2007-08-03 01:33:24 +02:00
|
|
|
RegQueryValueExW(hSubKey, name, NULL, NULL, (LPBYTE) buffer, &len);
|
2004-09-28 05:55:16 +02:00
|
|
|
|
2007-08-03 01:33:24 +02:00
|
|
|
WINE_TRACE("buffer=%s\n", wine_dbgstr_w(buffer));
|
2003-04-27 02:33:07 +02:00
|
|
|
end:
|
2011-03-11 09:04:37 +01:00
|
|
|
RegCloseKey(hSubKey);
|
2003-04-27 02:33:07 +02:00
|
|
|
|
2005-08-19 17:19:10 +02:00
|
|
|
return buffer;
|
2003-04-27 02:33:07 +02:00
|
|
|
}
|
|
|
|
|
2004-09-28 05:55:16 +02:00
|
|
|
/**
|
2004-11-30 22:03:36 +01:00
|
|
|
* set_config_key: convenience wrapper to set a key/value pair
|
2003-08-30 02:27:08 +02:00
|
|
|
*
|
2003-10-09 06:39:01 +02:00
|
|
|
* const char *subKey : the name of the config section
|
|
|
|
* const char *valueName : the name of the config value
|
|
|
|
* const char *value : the value to set the configuration key to
|
2003-08-30 02:27:08 +02:00
|
|
|
*
|
|
|
|
* Returns 0 on success, non-zero otherwise
|
2004-09-28 05:55:16 +02:00
|
|
|
*
|
|
|
|
* If valueName or value is NULL, an empty section will be created
|
2003-08-30 02:27:08 +02:00
|
|
|
*/
|
2010-12-15 22:30:18 +01:00
|
|
|
static int set_config_key(HKEY root, const WCHAR *subkey, REGSAM access, const WCHAR *name, const void *value, DWORD type)
|
|
|
|
{
|
2003-08-30 02:27:08 +02:00
|
|
|
DWORD res = 1;
|
|
|
|
HKEY key = NULL;
|
|
|
|
|
2007-08-03 01:33:24 +02:00
|
|
|
WINE_TRACE("subkey=%s: name=%s, value=%p, type=%d\n", wine_dbgstr_w(subkey),
|
|
|
|
wine_dbgstr_w(name), value, type);
|
2003-09-08 20:58:07 +02:00
|
|
|
|
|
|
|
assert( subkey != NULL );
|
2004-09-28 05:55:16 +02:00
|
|
|
|
2005-06-17 23:09:07 +02:00
|
|
|
if (subkey[0])
|
|
|
|
{
|
2010-12-15 22:30:18 +01:00
|
|
|
res = RegCreateKeyExW( root, subkey, 0, NULL, REG_OPTION_NON_VOLATILE,
|
|
|
|
access, NULL, &key, NULL );
|
2005-06-17 23:09:07 +02:00
|
|
|
if (res != ERROR_SUCCESS) goto end;
|
|
|
|
}
|
2005-06-23 13:42:54 +02:00
|
|
|
else key = root;
|
2004-09-28 05:55:16 +02:00
|
|
|
if (name == NULL || value == NULL) goto end;
|
2003-08-30 02:27:08 +02:00
|
|
|
|
2005-08-17 13:37:34 +02:00
|
|
|
switch (type)
|
|
|
|
{
|
2007-08-03 01:33:24 +02:00
|
|
|
case REG_SZ: res = RegSetValueExW(key, name, 0, REG_SZ, value, (lstrlenW(value)+1)*sizeof(WCHAR)); break;
|
|
|
|
case REG_DWORD: res = RegSetValueExW(key, name, 0, REG_DWORD, value, sizeof(DWORD)); break;
|
2005-08-17 13:37:34 +02:00
|
|
|
}
|
2003-08-30 02:27:08 +02:00
|
|
|
if (res != ERROR_SUCCESS) goto end;
|
|
|
|
|
|
|
|
res = 0;
|
|
|
|
end:
|
2005-06-23 13:42:54 +02:00
|
|
|
if (key && key != root) RegCloseKey(key);
|
2007-08-03 01:33:24 +02:00
|
|
|
if (res != 0)
|
|
|
|
WINE_ERR("Unable to set configuration key %s in section %s, res=%d\n",
|
|
|
|
wine_dbgstr_w(name), wine_dbgstr_w(subkey), res);
|
2003-08-30 02:27:08 +02:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2003-09-08 20:58:07 +02:00
|
|
|
/* ========================================================================= */
|
2004-09-28 05:55:16 +02:00
|
|
|
|
|
|
|
/* This code exists for the following reasons:
|
|
|
|
*
|
|
|
|
* - It makes working with the registry easier
|
|
|
|
* - By storing a mini cache of the registry, we can more easily implement
|
|
|
|
* cancel/revert and apply. The 'settings list' is an overlay on top of
|
|
|
|
* the actual registry data that we can write out at will.
|
|
|
|
*
|
|
|
|
* Rather than model a tree in memory, we simply store each absolute (rooted
|
|
|
|
* at the config key) path.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct setting
|
|
|
|
{
|
|
|
|
struct list entry;
|
2005-06-23 13:42:54 +02:00
|
|
|
HKEY root; /* the key on which path is rooted */
|
2007-08-03 01:33:24 +02:00
|
|
|
WCHAR *path; /* path in the registry rooted at root */
|
|
|
|
WCHAR *name; /* name of the registry value. if null, this means delete the key */
|
|
|
|
WCHAR *value; /* contents of the registry value. if null, this means delete the value */
|
2005-08-17 13:37:34 +02:00
|
|
|
DWORD type; /* type of registry value. REG_SZ or REG_DWORD for now */
|
2004-09-28 05:55:16 +02:00
|
|
|
};
|
|
|
|
|
2016-11-26 22:51:42 +01:00
|
|
|
static struct list settings = LIST_INIT(settings);
|
2004-09-28 05:55:16 +02:00
|
|
|
|
|
|
|
static void free_setting(struct setting *setting)
|
|
|
|
{
|
|
|
|
assert( setting != NULL );
|
2005-01-03 15:45:05 +01:00
|
|
|
assert( setting->path );
|
2004-09-28 05:55:16 +02:00
|
|
|
|
2007-08-03 01:33:24 +02:00
|
|
|
WINE_TRACE("destroying %p: %s\n", setting,
|
|
|
|
wine_dbgstr_w(setting->path));
|
|
|
|
|
2004-09-28 05:55:16 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, setting->path);
|
|
|
|
HeapFree(GetProcessHeap(), 0, setting->name);
|
2004-12-23 18:06:43 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, setting->value);
|
2004-09-28 05:55:16 +02:00
|
|
|
|
|
|
|
list_remove(&setting->entry);
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, setting);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the contents of the value at path. If not in the settings
|
|
|
|
* list, it will be fetched from the registry - failing that, the
|
|
|
|
* default will be used.
|
|
|
|
*
|
|
|
|
* If already in the list, the contents as given there will be
|
|
|
|
* returned. You are expected to HeapFree the result.
|
|
|
|
*/
|
2007-08-03 01:33:24 +02:00
|
|
|
WCHAR *get_reg_keyW(HKEY root, const WCHAR *path, const WCHAR *name, const WCHAR *def)
|
2004-09-28 05:55:16 +02:00
|
|
|
{
|
|
|
|
struct list *cursor;
|
|
|
|
struct setting *s;
|
2007-08-03 01:33:24 +02:00
|
|
|
WCHAR *val;
|
2004-09-28 05:55:16 +02:00
|
|
|
|
2007-08-03 01:33:24 +02:00
|
|
|
WINE_TRACE("path=%s, name=%s, def=%s\n", wine_dbgstr_w(path),
|
|
|
|
wine_dbgstr_w(name), wine_dbgstr_w(def));
|
2004-09-28 05:55:16 +02:00
|
|
|
|
|
|
|
/* check if it's in the list */
|
2016-11-26 22:51:42 +01:00
|
|
|
LIST_FOR_EACH( cursor, &settings )
|
2004-09-28 05:55:16 +02:00
|
|
|
{
|
|
|
|
s = LIST_ENTRY(cursor, struct setting, entry);
|
|
|
|
|
2005-06-23 13:42:54 +02:00
|
|
|
if (root != s->root) continue;
|
2007-08-03 01:33:24 +02:00
|
|
|
if (lstrcmpiW(path, s->path) != 0) continue;
|
2006-08-16 18:30:48 +02:00
|
|
|
if (!s->name) continue;
|
2007-08-03 01:33:24 +02:00
|
|
|
if (lstrcmpiW(name, s->name) != 0) continue;
|
2004-09-28 05:55:16 +02:00
|
|
|
|
2007-08-03 01:33:24 +02:00
|
|
|
WINE_TRACE("found %s:%s in settings list, returning %s\n",
|
|
|
|
wine_dbgstr_w(path), wine_dbgstr_w(name),
|
|
|
|
wine_dbgstr_w(s->value));
|
|
|
|
return s->value ? strdupW(s->value) : NULL;
|
2004-09-28 05:55:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* no, so get from the registry */
|
2005-06-23 13:42:54 +02:00
|
|
|
val = get_config_key(root, path, name, def);
|
2004-09-28 05:55:16 +02:00
|
|
|
|
2007-08-03 01:33:24 +02:00
|
|
|
WINE_TRACE("returning %s\n", wine_dbgstr_w(val));
|
2004-09-28 05:55:16 +02:00
|
|
|
|
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
2007-08-03 01:33:24 +02:00
|
|
|
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);
|
|
|
|
|
2007-08-07 12:38:11 +02:00
|
|
|
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);
|
|
|
|
}
|
2007-08-03 01:33:24 +02:00
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, wpath);
|
|
|
|
HeapFree(GetProcessHeap(), 0, wname);
|
|
|
|
HeapFree(GetProcessHeap(), 0, wdef);
|
|
|
|
HeapFree(GetProcessHeap(), 0, wRet);
|
|
|
|
|
|
|
|
return szRet;
|
|
|
|
}
|
|
|
|
|
2004-09-28 05:55:16 +02:00
|
|
|
/**
|
|
|
|
* Used to set a registry key.
|
|
|
|
*
|
|
|
|
* path is rooted at the config key, ie use "Version" or
|
|
|
|
* "AppDefaults\\fooapp.exe\\Version". You can use keypath()
|
|
|
|
* to get such a string.
|
|
|
|
*
|
2005-01-03 15:45:05 +01:00
|
|
|
* name is the value name, or NULL to delete the path.
|
2004-09-28 05:55:16 +02:00
|
|
|
*
|
|
|
|
* value is what to set the value to, or NULL to delete it.
|
|
|
|
*
|
2005-08-17 13:37:34 +02:00
|
|
|
* type is REG_SZ or REG_DWORD.
|
|
|
|
*
|
2004-09-28 05:55:16 +02:00
|
|
|
* These values will be copied when necessary.
|
|
|
|
*/
|
2007-08-03 01:33:24 +02:00
|
|
|
static void set_reg_key_ex(HKEY root, const WCHAR *path, const WCHAR *name, const void *value, DWORD type)
|
2004-09-28 05:55:16 +02:00
|
|
|
{
|
|
|
|
struct list *cursor;
|
|
|
|
struct setting *s;
|
|
|
|
|
|
|
|
assert( path != NULL );
|
|
|
|
|
2007-08-07 12:38:11 +02:00
|
|
|
WINE_TRACE("path=%s, name=%s, value=%s\n", wine_dbgstr_w(path),
|
2007-08-03 01:33:24 +02:00
|
|
|
wine_dbgstr_w(name), wine_dbgstr_w(value));
|
2004-09-28 05:55:16 +02:00
|
|
|
|
|
|
|
/* firstly, see if we already set this setting */
|
2016-11-26 22:51:42 +01:00
|
|
|
LIST_FOR_EACH( cursor, &settings )
|
2004-09-28 05:55:16 +02:00
|
|
|
{
|
|
|
|
struct setting *s = LIST_ENTRY(cursor, struct setting, entry);
|
|
|
|
|
2005-06-23 13:42:54 +02:00
|
|
|
if (root != s->root) continue;
|
2007-08-03 01:33:24 +02:00
|
|
|
if (lstrcmpiW(s->path, path) != 0) continue;
|
|
|
|
if ((s->name && name) && lstrcmpiW(s->name, name) != 0) continue;
|
2005-01-03 15:45:05 +01:00
|
|
|
|
|
|
|
/* are we attempting a double delete? */
|
|
|
|
if (!s->name && !name) return;
|
|
|
|
|
|
|
|
/* do we want to undelete this key? */
|
2007-08-03 01:33:24 +02:00
|
|
|
if (!s->name && name) s->name = strdupW(name);
|
2004-09-28 05:55:16 +02:00
|
|
|
|
|
|
|
/* yes, we have already set it, so just replace the content and return */
|
2004-12-23 18:06:43 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, s->value);
|
2005-08-17 13:37:34 +02:00
|
|
|
s->type = type;
|
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case REG_SZ:
|
2007-08-03 01:33:24 +02:00
|
|
|
s->value = value ? strdupW(value) : NULL;
|
2005-08-17 13:37:34 +02:00
|
|
|
break;
|
|
|
|
case REG_DWORD:
|
|
|
|
s->value = HeapAlloc(GetProcessHeap(), 0, sizeof(DWORD));
|
|
|
|
memcpy( s->value, value, sizeof(DWORD) );
|
|
|
|
break;
|
|
|
|
}
|
2004-09-28 05:55:16 +02:00
|
|
|
|
2005-01-03 15:45:05 +01:00
|
|
|
/* are we deleting this key? this won't remove any of the
|
|
|
|
* children from the overlay so if the user adds it again in
|
|
|
|
* that session it will appear to undelete the settings, but
|
|
|
|
* in reality only the settings actually modified by the user
|
|
|
|
* in that session will be restored. we might want to fix this
|
|
|
|
* corner case in future by actually deleting all the children
|
|
|
|
* here so that once it's gone, it's gone.
|
|
|
|
*/
|
|
|
|
if (!name) s->name = NULL;
|
|
|
|
|
2004-09-28 05:55:16 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* otherwise add a new setting for it */
|
|
|
|
s = HeapAlloc(GetProcessHeap(), 0, sizeof(struct setting));
|
2005-06-23 13:42:54 +02:00
|
|
|
s->root = root;
|
2007-08-03 01:33:24 +02:00
|
|
|
s->path = strdupW(path);
|
|
|
|
s->name = name ? strdupW(name) : NULL;
|
2005-08-17 13:37:34 +02:00
|
|
|
s->type = type;
|
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case REG_SZ:
|
2007-08-03 01:33:24 +02:00
|
|
|
s->value = value ? strdupW(value) : NULL;
|
2005-08-17 13:37:34 +02:00
|
|
|
break;
|
|
|
|
case REG_DWORD:
|
|
|
|
s->value = HeapAlloc(GetProcessHeap(), 0, sizeof(DWORD));
|
|
|
|
memcpy( s->value, value, sizeof(DWORD) );
|
|
|
|
break;
|
|
|
|
}
|
2004-09-28 05:55:16 +02:00
|
|
|
|
2016-11-26 22:51:42 +01:00
|
|
|
list_add_tail(&settings, &s->entry);
|
2003-09-08 20:58:07 +02:00
|
|
|
}
|
2003-08-30 02:27:08 +02:00
|
|
|
|
2005-08-17 13:37:34 +02:00
|
|
|
void set_reg_key(HKEY root, const char *path, const char *name, const char *value)
|
|
|
|
{
|
2007-08-09 03:07:05 +02:00
|
|
|
WCHAR *wpath, *wname = NULL, *wvalue = NULL;
|
2007-08-03 01:33:24 +02:00
|
|
|
|
|
|
|
wpath = HeapAlloc(GetProcessHeap(), 0, (strlen(path)+1)*sizeof(WCHAR));
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, path, -1, wpath, strlen(path)+1);
|
2007-08-09 03:07:05 +02:00
|
|
|
|
|
|
|
if (name)
|
|
|
|
{
|
|
|
|
wname = HeapAlloc(GetProcessHeap(), 0, (strlen(name)+1)*sizeof(WCHAR));
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, name, -1, wname, strlen(name)+1);
|
|
|
|
}
|
2007-08-04 03:34:57 +02:00
|
|
|
|
|
|
|
if (value)
|
|
|
|
{
|
|
|
|
wvalue = HeapAlloc(GetProcessHeap(), 0, (strlen(value)+1)*sizeof(WCHAR));
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, value, -1, wvalue, strlen(value)+1);
|
|
|
|
}
|
2007-08-03 01:33:24 +02:00
|
|
|
|
|
|
|
set_reg_key_ex(root, wpath, wname, wvalue, REG_SZ);
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, wpath);
|
|
|
|
HeapFree(GetProcessHeap(), 0, wname);
|
|
|
|
HeapFree(GetProcessHeap(), 0, wvalue);
|
2005-08-17 13:37:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void set_reg_key_dword(HKEY root, const char *path, const char *name, DWORD value)
|
|
|
|
{
|
2007-08-03 01:33:24 +02:00
|
|
|
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);
|
2005-08-17 13:37:34 +02:00
|
|
|
}
|
|
|
|
|
2008-04-25 14:36:25 +02:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2008-03-10 16:54:16 +01:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2004-09-28 05:55:16 +02:00
|
|
|
/**
|
|
|
|
* enumerates the value names at the given path, taking into account
|
|
|
|
* the changes in the settings list.
|
|
|
|
*
|
|
|
|
* you are expected to HeapFree each element of the array, which is null
|
|
|
|
* terminated, as well as the array itself.
|
|
|
|
*/
|
2009-01-26 12:52:34 +01:00
|
|
|
static WCHAR **enumerate_valuesW(HKEY root, WCHAR *path)
|
2004-09-28 05:55:16 +02:00
|
|
|
{
|
|
|
|
HKEY key;
|
2008-07-05 14:15:17 +02:00
|
|
|
DWORD res, i = 0, valueslen = 0;
|
2007-08-03 01:33:24 +02:00
|
|
|
WCHAR **values = NULL;
|
2004-09-28 05:55:16 +02:00
|
|
|
struct list *cursor;
|
|
|
|
|
2011-03-11 09:04:37 +01:00
|
|
|
res = RegOpenKeyExW(root, path, 0, MAXIMUM_ALLOWED, &key);
|
2004-09-28 05:55:16 +02:00
|
|
|
if (res == ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
while (TRUE)
|
|
|
|
{
|
2007-08-03 01:33:24 +02:00
|
|
|
WCHAR name[1024];
|
2008-10-26 15:27:05 +01:00
|
|
|
DWORD namesize = sizeof(name)/sizeof(name[0]);
|
2004-09-28 05:55:16 +02:00
|
|
|
BOOL removed = FALSE;
|
|
|
|
|
|
|
|
/* find out the needed size, allocate a buffer, read the value */
|
2007-08-03 01:33:24 +02:00
|
|
|
if ((res = RegEnumValueW(key, i, name, &namesize, NULL, NULL, NULL, NULL)) != ERROR_SUCCESS)
|
2004-09-28 05:55:16 +02:00
|
|
|
break;
|
|
|
|
|
2007-08-03 01:33:24 +02:00
|
|
|
WINE_TRACE("name=%s\n", wine_dbgstr_w(name));
|
2004-09-28 05:55:16 +02:00
|
|
|
|
|
|
|
/* check if this value name has been removed in the settings list */
|
2016-11-26 22:51:42 +01:00
|
|
|
LIST_FOR_EACH( cursor, &settings )
|
2004-09-28 05:55:16 +02:00
|
|
|
{
|
|
|
|
struct setting *s = LIST_ENTRY(cursor, struct setting, entry);
|
2007-08-03 01:33:24 +02:00
|
|
|
if (lstrcmpiW(s->path, path) != 0) continue;
|
|
|
|
if (lstrcmpiW(s->name, name) != 0) continue;
|
2004-09-28 05:55:16 +02:00
|
|
|
|
|
|
|
if (!s->value)
|
|
|
|
{
|
|
|
|
WINE_TRACE("this key has been removed, so skipping\n");
|
|
|
|
removed = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (removed) /* this value was deleted by the user, so don't include it */
|
|
|
|
{
|
|
|
|
i++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* grow the array if necessary, add buffer to it, iterate */
|
2007-08-03 01:33:24 +02:00
|
|
|
if (values) values = HeapReAlloc(GetProcessHeap(), 0, values, sizeof(WCHAR*) * (valueslen + 1));
|
|
|
|
else values = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR*));
|
2004-09-28 05:55:16 +02:00
|
|
|
|
2007-08-03 01:33:24 +02:00
|
|
|
values[valueslen++] = strdupW(name);
|
2004-09-28 05:55:16 +02:00
|
|
|
WINE_TRACE("valueslen is now %d\n", valueslen);
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-08-03 01:33:24 +02:00
|
|
|
WINE_WARN("failed opening registry key %s, res=0x%x\n",
|
|
|
|
wine_dbgstr_w(path), res);
|
2004-09-28 05:55:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
WINE_TRACE("adding settings in list but not registry\n");
|
|
|
|
|
|
|
|
/* now we have to add the values that aren't in the registry but are in the settings list */
|
2016-11-26 22:51:42 +01:00
|
|
|
LIST_FOR_EACH( cursor, &settings )
|
2004-09-28 05:55:16 +02:00
|
|
|
{
|
|
|
|
struct setting *setting = LIST_ENTRY(cursor, struct setting, entry);
|
|
|
|
BOOL found = FALSE;
|
|
|
|
|
2007-08-03 01:33:24 +02:00
|
|
|
if (lstrcmpiW(setting->path, path) != 0) continue;
|
2004-09-28 05:55:16 +02:00
|
|
|
|
|
|
|
if (!setting->value) continue;
|
|
|
|
|
|
|
|
for (i = 0; i < valueslen; i++)
|
|
|
|
{
|
2007-08-03 01:33:24 +02:00
|
|
|
if (lstrcmpiW(setting->name, values[i]) == 0)
|
2004-09-28 05:55:16 +02:00
|
|
|
{
|
|
|
|
found = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (found) continue;
|
|
|
|
|
2007-08-03 01:33:24 +02:00
|
|
|
WINE_TRACE("%s in list but not registry\n", wine_dbgstr_w(setting->name));
|
2004-09-28 05:55:16 +02:00
|
|
|
|
|
|
|
/* otherwise it's been set by the user but isn't in the registry */
|
2007-08-03 01:33:24 +02:00
|
|
|
if (values) values = HeapReAlloc(GetProcessHeap(), 0, values, sizeof(WCHAR*) * (valueslen + 1));
|
|
|
|
else values = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR*));
|
2004-09-28 05:55:16 +02:00
|
|
|
|
2007-08-03 01:33:24 +02:00
|
|
|
values[valueslen++] = strdupW(setting->name);
|
2003-09-08 20:58:07 +02:00
|
|
|
}
|
|
|
|
|
2004-09-28 05:55:16 +02:00
|
|
|
WINE_TRACE("adding null terminator\n");
|
|
|
|
if (values)
|
|
|
|
{
|
2007-08-03 01:33:24 +02:00
|
|
|
values = HeapReAlloc(GetProcessHeap(), 0, values, sizeof(WCHAR*) * (valueslen + 1));
|
2004-09-28 05:55:16 +02:00
|
|
|
values[valueslen] = NULL;
|
2003-09-10 05:41:44 +02:00
|
|
|
}
|
2004-09-28 05:55:16 +02:00
|
|
|
|
|
|
|
RegCloseKey(key);
|
|
|
|
|
|
|
|
return values;
|
2003-09-08 20:58:07 +02:00
|
|
|
}
|
|
|
|
|
2007-08-03 01:33:24 +02:00
|
|
|
char **enumerate_values(HKEY root, char *path)
|
|
|
|
{
|
|
|
|
WCHAR *wpath;
|
|
|
|
WCHAR **wret;
|
|
|
|
char **ret=NULL;
|
2017-12-18 15:33:08 +01:00
|
|
|
int i=0, len=0, size;
|
2007-08-03 01:33:24 +02:00
|
|
|
|
|
|
|
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++)
|
|
|
|
{
|
2017-12-18 15:33:08 +01:00
|
|
|
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]);
|
|
|
|
}
|
2007-08-03 01:33:24 +02:00
|
|
|
}
|
2007-08-06 17:07:31 +02:00
|
|
|
ret[len] = NULL;
|
2007-08-03 01:33:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, wpath);
|
|
|
|
HeapFree(GetProcessHeap(), 0, wret);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2004-09-28 05:55:16 +02:00
|
|
|
/**
|
|
|
|
* returns true if the given key/value pair exists in the registry or
|
|
|
|
* has been written to.
|
|
|
|
*/
|
2005-06-23 13:42:54 +02:00
|
|
|
BOOL reg_key_exists(HKEY root, const char *path, const char *name)
|
2004-09-28 05:55:16 +02:00
|
|
|
{
|
2005-06-23 13:42:54 +02:00
|
|
|
char *val = get_reg_key(root, path, name, NULL);
|
2004-09-28 05:55:16 +02:00
|
|
|
|
|
|
|
if (val)
|
|
|
|
{
|
|
|
|
HeapFree(GetProcessHeap(), 0, val);
|
|
|
|
return TRUE;
|
2003-09-08 20:58:07 +02:00
|
|
|
}
|
2004-09-28 05:55:16 +02:00
|
|
|
|
|
|
|
return FALSE;
|
2003-09-08 20:58:07 +02:00
|
|
|
}
|
|
|
|
|
2004-09-28 05:55:16 +02:00
|
|
|
static void process_setting(struct setting *s)
|
2003-09-10 05:41:44 +02:00
|
|
|
{
|
2010-12-15 22:30:18 +01:00
|
|
|
static const WCHAR softwareW[] = {'S','o','f','t','w','a','r','e','\\'};
|
|
|
|
HKEY key;
|
|
|
|
BOOL needs_wow64 = (is_win64 && s->root == HKEY_LOCAL_MACHINE && s->path &&
|
|
|
|
!strncmpiW( s->path, softwareW, sizeof(softwareW)/sizeof(WCHAR) ));
|
|
|
|
|
2004-09-28 05:55:16 +02:00
|
|
|
if (s->value)
|
|
|
|
{
|
2007-08-03 01:33:24 +02:00
|
|
|
WINE_TRACE("Setting %s:%s to '%s'\n", wine_dbgstr_w(s->path),
|
|
|
|
wine_dbgstr_w(s->name), wine_dbgstr_w(s->value));
|
2010-12-15 22:30:18 +01:00
|
|
|
set_config_key(s->root, s->path, MAXIMUM_ALLOWED, s->name, s->value, s->type);
|
|
|
|
if (needs_wow64)
|
|
|
|
{
|
|
|
|
WINE_TRACE("Setting 32-bit %s:%s to '%s'\n", wine_dbgstr_w(s->path),
|
|
|
|
wine_dbgstr_w(s->name), wine_dbgstr_w(s->value));
|
|
|
|
set_config_key(s->root, s->path, MAXIMUM_ALLOWED | KEY_WOW64_32KEY, s->name, s->value, s->type);
|
|
|
|
}
|
2004-09-28 05:55:16 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-12-15 22:30:18 +01:00
|
|
|
WINE_TRACE("Removing %s:%s\n", wine_dbgstr_w(s->path), wine_dbgstr_w(s->name));
|
2011-03-11 09:04:37 +01:00
|
|
|
if (!RegOpenKeyExW( s->root, s->path, 0, MAXIMUM_ALLOWED, &key ))
|
2010-12-15 22:30:18 +01:00
|
|
|
{
|
|
|
|
/* NULL name means remove that path/section entirely */
|
|
|
|
if (s->name) RegDeleteValueW( key, s->name );
|
2011-08-26 14:28:11 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
RegDeleteTreeW( key, NULL );
|
|
|
|
RegDeleteKeyW( s->root, s->path );
|
|
|
|
}
|
2010-12-15 22:30:18 +01:00
|
|
|
RegCloseKey( key );
|
|
|
|
}
|
|
|
|
if (needs_wow64)
|
|
|
|
{
|
|
|
|
WINE_TRACE("Removing 32-bit %s:%s\n", wine_dbgstr_w(s->path), wine_dbgstr_w(s->name));
|
|
|
|
if (!RegOpenKeyExW( s->root, s->path, 0, MAXIMUM_ALLOWED | KEY_WOW64_32KEY, &key ))
|
|
|
|
{
|
|
|
|
if (s->name) RegDeleteValueW( key, s->name );
|
2011-08-26 14:28:11 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
RegDeleteTreeW( key, NULL );
|
|
|
|
RegDeleteKeyExW( s->root, s->path, KEY_WOW64_32KEY, 0 );
|
|
|
|
}
|
2010-12-15 22:30:18 +01:00
|
|
|
RegCloseKey( key );
|
|
|
|
}
|
|
|
|
}
|
2004-09-28 05:55:16 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void apply(void)
|
|
|
|
{
|
2016-11-26 22:51:42 +01:00
|
|
|
if (list_empty(&settings)) return; /* we will be called for each page when the user clicks OK */
|
2004-09-28 05:55:16 +02:00
|
|
|
|
|
|
|
WINE_TRACE("()\n");
|
|
|
|
|
2016-11-26 22:51:42 +01:00
|
|
|
while (!list_empty(&settings))
|
2004-09-28 05:55:16 +02:00
|
|
|
{
|
2016-11-26 22:51:42 +01:00
|
|
|
struct setting *s = (struct setting *) list_head(&settings);
|
2004-09-28 05:55:16 +02:00
|
|
|
process_setting(s);
|
|
|
|
free_setting(s);
|
2003-09-08 20:58:07 +02:00
|
|
|
}
|
2003-03-31 21:41:55 +02:00
|
|
|
}
|
2003-09-10 05:41:44 +02:00
|
|
|
|
|
|
|
/* ================================== utility functions ============================ */
|
|
|
|
|
2006-08-16 18:30:48 +02:00
|
|
|
WCHAR* current_app = NULL; /* the app we are currently editing, or NULL if editing global */
|
2004-09-28 05:16:43 +02:00
|
|
|
|
|
|
|
/* returns a registry key path suitable for passing to addTransaction */
|
2005-06-02 17:11:32 +02:00
|
|
|
char *keypath(const char *section)
|
2004-09-28 05:16:43 +02:00
|
|
|
{
|
|
|
|
static char *result = NULL;
|
2004-09-28 05:55:16 +02:00
|
|
|
|
2004-12-23 18:06:43 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, result);
|
2004-09-28 05:16:43 +02:00
|
|
|
|
2004-11-23 14:50:23 +01:00
|
|
|
if (current_app)
|
2004-09-28 05:16:43 +02:00
|
|
|
{
|
2006-08-16 18:30:48 +02:00
|
|
|
result = HeapAlloc(GetProcessHeap(), 0, strlen("AppDefaults\\") + lstrlenW(current_app)*2 + 2 /* \\ */ + strlen(section) + 1 /* terminator */);
|
2012-01-20 12:42:33 +01:00
|
|
|
wsprintfA(result, "AppDefaults\\%ls", current_app);
|
2005-06-17 23:09:07 +02:00
|
|
|
if (section[0]) sprintf( result + strlen(result), "\\%s", section );
|
2004-09-28 05:16:43 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
result = strdupA(section);
|
|
|
|
}
|
2004-09-28 05:55:16 +02:00
|
|
|
|
2004-09-28 05:16:43 +02:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2008-04-25 14:36:25 +02:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2004-05-04 04:56:46 +02:00
|
|
|
void PRINTERROR(void)
|
|
|
|
{
|
|
|
|
LPSTR msg;
|
|
|
|
|
|
|
|
FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM,
|
|
|
|
0, GetLastError(), MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT),
|
|
|
|
(LPSTR)&msg, 0, NULL);
|
2004-11-23 14:50:23 +01:00
|
|
|
|
|
|
|
/* eliminate trailing newline, is this a Wine bug? */
|
2005-01-10 15:26:46 +01:00
|
|
|
*(strrchr(msg, '\r')) = '\0';
|
2004-11-23 14:50:23 +01:00
|
|
|
|
2004-05-04 04:56:46 +02:00
|
|
|
WINE_TRACE("error: '%s'\n", msg);
|
|
|
|
}
|
2004-09-28 05:55:16 +02:00
|
|
|
|
2013-10-16 23:38:33 +02:00
|
|
|
BOOL initialize(HINSTANCE hInstance)
|
2005-12-17 12:30:06 +01:00
|
|
|
{
|
2012-01-20 12:42:33 +01:00
|
|
|
DWORD res = RegCreateKeyA(HKEY_CURRENT_USER, WINE_KEY_ROOT, &config_key);
|
2004-09-28 05:55:16 +02:00
|
|
|
|
|
|
|
if (res != ERROR_SUCCESS) {
|
2006-10-02 23:19:18 +02:00
|
|
|
WINE_ERR("RegOpenKey failed on wine config key (%d)\n", res);
|
2013-10-16 23:38:33 +02:00
|
|
|
return TRUE;
|
2004-09-28 05:55:16 +02:00
|
|
|
}
|
|
|
|
|
2013-10-16 23:38:33 +02:00
|
|
|
return FALSE;
|
2004-09-28 05:55:16 +02:00
|
|
|
}
|