mirror of
git://source.winehq.org/git/wine.git
synced 2024-08-31 07:34:06 +00:00
reg: Consistently use 'hkey' for HKEY variables.
Signed-off-by: Hugh McMaster <hugh.mcmaster@outlook.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
22a7059f98
commit
c809f94624
|
@ -152,10 +152,10 @@ static LPBYTE get_regdata(const WCHAR *data, DWORD reg_type, WCHAR separator, DW
|
|||
static int run_add(HKEY root, WCHAR *path, WCHAR *value_name, BOOL value_empty,
|
||||
WCHAR *type, WCHAR separator, WCHAR *data, BOOL force)
|
||||
{
|
||||
HKEY key;
|
||||
HKEY hkey;
|
||||
|
||||
if (RegCreateKeyExW(root, path, 0, NULL, REG_OPTION_NON_VOLATILE,
|
||||
KEY_READ|KEY_WRITE, NULL, &key, NULL))
|
||||
KEY_READ|KEY_WRITE, NULL, &hkey, NULL))
|
||||
{
|
||||
output_message(STRING_INVALID_KEY);
|
||||
return 1;
|
||||
|
@ -169,11 +169,11 @@ static int run_add(HKEY root, WCHAR *path, WCHAR *value_name, BOOL value_empty,
|
|||
|
||||
if (!force)
|
||||
{
|
||||
if (RegQueryValueExW(key, value_name, NULL, NULL, NULL, NULL) == ERROR_SUCCESS)
|
||||
if (RegQueryValueExW(hkey, value_name, NULL, NULL, NULL, NULL) == ERROR_SUCCESS)
|
||||
{
|
||||
if (!ask_confirm(STRING_OVERWRITE_VALUE, value_name))
|
||||
{
|
||||
RegCloseKey(key);
|
||||
RegCloseKey(hkey);
|
||||
output_message(STRING_CANCELLED);
|
||||
return 0;
|
||||
}
|
||||
|
@ -183,28 +183,28 @@ static int run_add(HKEY root, WCHAR *path, WCHAR *value_name, BOOL value_empty,
|
|||
reg_type = wchar_get_type(type);
|
||||
if (reg_type == ~0u)
|
||||
{
|
||||
RegCloseKey(key);
|
||||
RegCloseKey(hkey);
|
||||
output_message(STRING_UNSUPPORTED_TYPE, type);
|
||||
return 1;
|
||||
}
|
||||
if ((reg_type == REG_DWORD || reg_type == REG_DWORD_BIG_ENDIAN) && !data)
|
||||
{
|
||||
RegCloseKey(key);
|
||||
RegCloseKey(hkey);
|
||||
output_message(STRING_INVALID_CMDLINE);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!(reg_data = get_regdata(data, reg_type, separator, ®_count)))
|
||||
{
|
||||
RegCloseKey(key);
|
||||
RegCloseKey(hkey);
|
||||
return 1;
|
||||
}
|
||||
|
||||
RegSetValueExW(key, value_name, 0, reg_type, reg_data, reg_count);
|
||||
RegSetValueExW(hkey, value_name, 0, reg_type, reg_data, reg_count);
|
||||
free(reg_data);
|
||||
}
|
||||
|
||||
RegCloseKey(key);
|
||||
RegCloseKey(hkey);
|
||||
output_message(STRING_SUCCESS);
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
static int run_delete(HKEY root, WCHAR *path, WCHAR *key_name, WCHAR *value_name,
|
||||
BOOL value_empty, BOOL value_all, BOOL force)
|
||||
{
|
||||
HKEY key;
|
||||
HKEY hkey;
|
||||
|
||||
if (!force)
|
||||
{
|
||||
|
@ -53,7 +53,7 @@ static int run_delete(HKEY root, WCHAR *path, WCHAR *key_name, WCHAR *value_name
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (RegOpenKeyExW(root, path, 0, KEY_READ|KEY_SET_VALUE, &key))
|
||||
if (RegOpenKeyExW(root, path, 0, KEY_READ|KEY_SET_VALUE, &hkey))
|
||||
{
|
||||
output_message(STRING_KEY_NONEXIST);
|
||||
return 1;
|
||||
|
@ -70,14 +70,14 @@ static int run_delete(HKEY root, WCHAR *path, WCHAR *key_name, WCHAR *value_name
|
|||
while (1)
|
||||
{
|
||||
value_len = max_value_len;
|
||||
rc = RegEnumValueW(key, 0, value_name, &value_len, NULL, NULL, NULL, NULL);
|
||||
rc = RegEnumValueW(hkey, 0, value_name, &value_len, NULL, NULL, NULL, NULL);
|
||||
if (rc == ERROR_SUCCESS)
|
||||
{
|
||||
rc = RegDeleteValueW(key, value_name);
|
||||
rc = RegDeleteValueW(hkey, value_name);
|
||||
if (rc != ERROR_SUCCESS)
|
||||
{
|
||||
free(value_name);
|
||||
RegCloseKey(key);
|
||||
RegCloseKey(hkey);
|
||||
output_message(STRING_VALUEALL_FAILED, key_name);
|
||||
return 1;
|
||||
}
|
||||
|
@ -93,15 +93,15 @@ static int run_delete(HKEY root, WCHAR *path, WCHAR *key_name, WCHAR *value_name
|
|||
}
|
||||
else if (value_name || value_empty)
|
||||
{
|
||||
if (RegDeleteValueW(key, value_name))
|
||||
if (RegDeleteValueW(hkey, value_name))
|
||||
{
|
||||
RegCloseKey(key);
|
||||
RegCloseKey(hkey);
|
||||
output_message(STRING_VALUE_NONEXIST);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
RegCloseKey(key);
|
||||
RegCloseKey(hkey);
|
||||
output_message(STRING_SUCCESS);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -225,7 +225,7 @@ static void export_key_name(HANDLE hFile, WCHAR *name)
|
|||
free(buf);
|
||||
}
|
||||
|
||||
static int export_registry_data(HANDLE hFile, HKEY key, WCHAR *path)
|
||||
static int export_registry_data(HANDLE hFile, HKEY hkey, WCHAR *path)
|
||||
{
|
||||
LONG rc;
|
||||
DWORD max_value_len = 256, value_len;
|
||||
|
@ -246,7 +246,7 @@ static int export_registry_data(HANDLE hFile, HKEY key, WCHAR *path)
|
|||
{
|
||||
value_len = max_value_len;
|
||||
data_size = max_data_bytes;
|
||||
rc = RegEnumValueW(key, i, value_name, &value_len, NULL, &type, data, &data_size);
|
||||
rc = RegEnumValueW(hkey, i, value_name, &value_len, NULL, &type, data, &data_size);
|
||||
|
||||
if (rc == ERROR_SUCCESS)
|
||||
{
|
||||
|
@ -280,11 +280,11 @@ static int export_registry_data(HANDLE hFile, HKEY key, WCHAR *path)
|
|||
for (;;)
|
||||
{
|
||||
subkey_len = MAX_SUBKEY_LEN;
|
||||
rc = RegEnumKeyExW(key, i, subkey_name, &subkey_len, NULL, NULL, NULL, NULL);
|
||||
rc = RegEnumKeyExW(hkey, i, subkey_name, &subkey_len, NULL, NULL, NULL, NULL);
|
||||
if (rc == ERROR_SUCCESS)
|
||||
{
|
||||
subkey_path = build_subkey_path(path, path_len, subkey_name, subkey_len);
|
||||
if (!RegOpenKeyExW(key, subkey_name, 0, KEY_READ, &subkey))
|
||||
if (!RegOpenKeyExW(hkey, subkey_name, 0, KEY_READ, &subkey))
|
||||
{
|
||||
export_registry_data(hFile, subkey, subkey_path);
|
||||
RegCloseKey(subkey);
|
||||
|
|
|
@ -133,7 +133,7 @@ static void output_value(const WCHAR *value_name, DWORD type, BYTE *data, DWORD
|
|||
|
||||
static unsigned int num_values_found = 0;
|
||||
|
||||
static int query_value(HKEY key, WCHAR *value_name, WCHAR *path, BOOL recurse)
|
||||
static int query_value(HKEY hkey, WCHAR *value_name, WCHAR *path, BOOL recurse)
|
||||
{
|
||||
LONG rc;
|
||||
DWORD max_data_bytes = 2048, data_size;
|
||||
|
@ -149,7 +149,7 @@ static int query_value(HKEY key, WCHAR *value_name, WCHAR *path, BOOL recurse)
|
|||
for (;;)
|
||||
{
|
||||
data_size = max_data_bytes;
|
||||
rc = RegQueryValueExW(key, value_name, NULL, &type, data, &data_size);
|
||||
rc = RegQueryValueExW(hkey, value_name, NULL, &type, data, &data_size);
|
||||
if (rc == ERROR_MORE_DATA)
|
||||
{
|
||||
max_data_bytes = data_size;
|
||||
|
@ -191,11 +191,11 @@ static int query_value(HKEY key, WCHAR *value_name, WCHAR *path, BOOL recurse)
|
|||
for (;;)
|
||||
{
|
||||
subkey_len = MAX_SUBKEY_LEN;
|
||||
rc = RegEnumKeyExW(key, i, subkey_name, &subkey_len, NULL, NULL, NULL, NULL);
|
||||
rc = RegEnumKeyExW(hkey, i, subkey_name, &subkey_len, NULL, NULL, NULL, NULL);
|
||||
if (rc == ERROR_SUCCESS)
|
||||
{
|
||||
subkey_path = build_subkey_path(path, path_len, subkey_name, subkey_len);
|
||||
if (!RegOpenKeyExW(key, subkey_name, 0, KEY_READ, &subkey))
|
||||
if (!RegOpenKeyExW(hkey, subkey_name, 0, KEY_READ, &subkey))
|
||||
{
|
||||
query_value(subkey, value_name, subkey_path, recurse);
|
||||
RegCloseKey(subkey);
|
||||
|
@ -210,7 +210,7 @@ static int query_value(HKEY key, WCHAR *value_name, WCHAR *path, BOOL recurse)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int query_all(HKEY key, WCHAR *path, BOOL recurse)
|
||||
static int query_all(HKEY hkey, WCHAR *path, BOOL recurse)
|
||||
{
|
||||
LONG rc;
|
||||
DWORD max_value_len = 256, value_len;
|
||||
|
@ -231,7 +231,7 @@ static int query_all(HKEY key, WCHAR *path, BOOL recurse)
|
|||
{
|
||||
value_len = max_value_len;
|
||||
data_size = max_data_bytes;
|
||||
rc = RegEnumValueW(key, i, value_name, &value_len, NULL, &type, data, &data_size);
|
||||
rc = RegEnumValueW(hkey, i, value_name, &value_len, NULL, &type, data, &data_size);
|
||||
if (rc == ERROR_SUCCESS)
|
||||
{
|
||||
output_value(value_name, type, data, data_size);
|
||||
|
@ -267,13 +267,13 @@ static int query_all(HKEY key, WCHAR *path, BOOL recurse)
|
|||
for (;;)
|
||||
{
|
||||
subkey_len = MAX_SUBKEY_LEN;
|
||||
rc = RegEnumKeyExW(key, i, subkey_name, &subkey_len, NULL, NULL, NULL, NULL);
|
||||
rc = RegEnumKeyExW(hkey, i, subkey_name, &subkey_len, NULL, NULL, NULL, NULL);
|
||||
if (rc == ERROR_SUCCESS)
|
||||
{
|
||||
if (recurse)
|
||||
{
|
||||
subkey_path = build_subkey_path(path, path_len, subkey_name, subkey_len);
|
||||
if (!RegOpenKeyExW(key, subkey_name, 0, KEY_READ, &subkey))
|
||||
if (!RegOpenKeyExW(hkey, subkey_name, 0, KEY_READ, &subkey))
|
||||
{
|
||||
query_all(subkey, subkey_path, recurse);
|
||||
RegCloseKey(subkey);
|
||||
|
@ -297,10 +297,10 @@ static int query_all(HKEY key, WCHAR *path, BOOL recurse)
|
|||
static int run_query(HKEY root, WCHAR *path, WCHAR *key_name, WCHAR *value_name,
|
||||
BOOL value_empty, BOOL recurse)
|
||||
{
|
||||
HKEY key;
|
||||
HKEY hkey;
|
||||
int ret;
|
||||
|
||||
if (RegOpenKeyExW(root, path, 0, KEY_READ, &key) != ERROR_SUCCESS)
|
||||
if (RegOpenKeyExW(root, path, 0, KEY_READ, &hkey) != ERROR_SUCCESS)
|
||||
{
|
||||
output_message(STRING_KEY_NONEXIST);
|
||||
return 1;
|
||||
|
@ -310,14 +310,14 @@ static int run_query(HKEY root, WCHAR *path, WCHAR *key_name, WCHAR *value_name,
|
|||
|
||||
if (value_name || value_empty)
|
||||
{
|
||||
ret = query_value(key, value_name, key_name, recurse);
|
||||
ret = query_value(hkey, value_name, key_name, recurse);
|
||||
if (recurse)
|
||||
output_message(STRING_MATCHES_FOUND, num_values_found);
|
||||
}
|
||||
else
|
||||
ret = query_all(key, key_name, recurse);
|
||||
ret = query_all(hkey, key_name, recurse);
|
||||
|
||||
RegCloseKey(key);
|
||||
RegCloseKey(hkey);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue