-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathregistry.cpp
57 lines (41 loc) · 1.12 KB
/
registry.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include <mbstring.h>
#include "main.h"
#include "eventlog.h"
// List of registry items to store //
struct RegistryData {
char * name; // Name of key //
DWORD key_type; // Type of key //
void * value; // Value of key //
DWORD size; // Size of key //
int required; // Key is required //
};
// Location of eventlog keys //
static char RegistryEventlogKeyPath[] = "SYSTEM\\CurrentControlSet\\Services\\Eventlog";
int RegistryGather()
{
DWORD size;
HKEY registry_handle;
char name[EVENTLOG_NAME_SZ]; /*128*/
int errnum;
int index;
if (RegOpenKey(HKEY_LOCAL_MACHINE, RegistryEventlogKeyPath, ®istry_handle)) {
printf( "Cannot initialize access to registry: \"%s\"", RegistryEventlogKeyPath);
return 1;
}
index = 0;
while (1) {
size = sizeof(name);
errnum = RegEnumKey(registry_handle, index, name, size);
if (errnum == ERROR_NO_MORE_ITEMS)
break;
if (errnum) {
printf("Cannot enumerate registry key: \"%s\"", RegistryEventlogKeyPath);
break;
}
if (EventlogCreate(name))
break;
index++;
}
RegCloseKey(registry_handle);
return errnum != ERROR_NO_MORE_ITEMS;
}