1
/* Copyright Paul Lin 2003. Distributed under the Boost */
2
/* Software License, Version 1.0. (See accompanying */
3
/* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) */
2
Copyright Paul Lin 2003. Copyright 2006 Bojan Resnik.
3
Distributed under the Boost Software License, Version 1.0. (See accompanying
4
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
15
17
# define WIN32_LEAN_AND_MEAN
16
18
# include <windows.h>
18
# define MAX_REGISTRY_DATA_LENGTH 4096
20
# define MAX_REGISTRY_DATA_LENGTH 4096
21
# define MAX_REGISTRY_KEYNAME_LENGTH 256
22
# define MAX_REGISTRY_VALUENAME_LENGTH 16384
40
static HKEY get_key(char const** path)
44
for (p = dlRootKeys; p->name; ++p)
46
int n = strlen(p->name);
47
if (!strncmp(*path,p->name,n))
49
if ((*path)[n] == '\\' || (*path)[n] == 0)
37
61
builtin_system_registry(
41
65
char const* path = lol_get(frame->args, 0)->string;
67
HKEY key = get_key(&path);
48
for (p = dlRootKeys; p->name; ++p)
50
int n = strlen(p->name);
51
if (!strncmp(path,p->name,n))
53
if (path[n] == '\\' || path[n] == 0)
66
71
&& ERROR_SUCCESS == RegOpenKeyEx(key, path, 0, KEY_QUERY_VALUE, &key)
133
static LIST* get_subkey_names(HKEY key, char const* path)
137
if ( ERROR_SUCCESS ==
138
RegOpenKeyEx(key, path, 0, KEY_ENUMERATE_SUB_KEYS, &key)
141
char name[MAX_REGISTRY_KEYNAME_LENGTH];
142
DWORD name_size = sizeof(name);
144
FILETIME last_write_time;
147
ERROR_SUCCESS == RegEnumKeyEx(
148
key, index, name, &name_size, 0, 0, 0, &last_write_time);
150
name_size = sizeof(name)
154
result = list_append(result, list_new(0, newstr(name)));
163
static LIST* get_value_names(HKEY key, char const* path)
167
if ( ERROR_SUCCESS == RegOpenKeyEx(key, path, 0, KEY_QUERY_VALUE, &key) )
169
char name[MAX_REGISTRY_VALUENAME_LENGTH];
170
DWORD name_size = sizeof(name);
174
ERROR_SUCCESS == RegEnumValue(
175
key, index, name, &name_size, 0, 0, 0, 0);
177
name_size = sizeof(name)
181
result = list_append(result, list_new(0, newstr(name)));
191
builtin_system_registry_names(
195
char const* path = lol_get(frame->args, 0)->string;
196
char const* result_type = lol_get(frame->args, 1)->string;
198
HKEY key = get_key(&path);
200
if ( !strcmp(result_type, "subkeys") )
201
return get_subkey_names(key, path);
202
if ( !strcmp(result_type, "values") )
203
return get_value_names(key, path);