• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

Registry/H05-May-2020-2,8332,323

documentation/H03-May-2022-

samples/H03-May-2022-2,0791,457

testing/H05-May-2020-130103

tests/H05-May-2020-612417

.gitignoreH A D05-May-202026 66

.travis.ymlH A D05-May-2020664 2418

MANIFEST.inH A D05-May-202062 31

README.MDH A D05-May-20203.2 KiB10272

setup.pyH A D05-May-2020723 2116

README.MD

1
2python-registry
3===============
4
5Introduction
6------------
7python-registry is a pure Python library that provides read-only
8access to Windows NT Registry files.
9These include NTUSER.DAT, userdiff, and SAM. The interface is two-fold:
10a high-level interface suitable for most tasks, and a low level
11set of parsing objects and methods which may be used for advanced
12study of the Windows NT Registry. The library is portable across all
13major platforms.
14
15Usage
16-----
17
18Most users will find the `Registry.Registry` module most appropriate.
19The module exposes three classes: the `Registry`, the `RegistryKey`,
20and the `RegistryValue`. The `Registry` organizes parsing and access
21to the Windows Registry file. The `RegistryKey` is a convenient
22interface into the tree-like structure of the Windows NT Registry.
23A `RegistryKey` may have children `RegistryKeys`, and may also have
24values associated with it. A `RegistryValue` can be thought of as
25the tuple (name, datatype, value) associated with a `RegistryKey`.
26python-registry supports all major datatypes, such as `RegSZ`,
27`RegDWord`, and `RegBin`.
28
29To open a Windows Registry file, its this easy:
30
31
32    import sys
33    from Registry import Registry
34
35    reg = Registry.Registry(sys.argv[1])
36
37
38Print all keys in a Registry
39
40
41    def rec(key, depth=0):
42        print "\t" * depth + key.path()
43
44        for subkey in key.subkeys():
45            rec(subkey, depth + 1)
46
47    rec(reg.root())
48
49
50Find a key and print all string values
51
52
53    try:
54        key = reg.open("SOFTWARE\\Microsoft\\Windows\\Current Version\\Run")
55    except Registry.RegistryKeyNotFoundException:
56        print "Couldn't find Run key. Exiting..."
57        sys.exit(-1)
58
59    for value in [v for v in key.values() \
60                       if v.value_type() == Registry.RegSZ or \
61                          v.value_type() == Registry.RegExpandSZ]:
62        print "%s: %s" % (value.name(), value.value())
63
64
65Advanced users who wish to study the structure of the Windows
66Registry may find the `Registry.RegistryParse` module useful.
67This module implements all known structures of the Windows Registry.
68
69Wanted
70------
71  - Bug reports.
72  - Feedback.
73
74python-registry was originally developed to scratch one of
75the author's itches.  Now he hopes it can be of use to
76someone outside of his lonely NYC apartment.
77
78
79License
80-------
81As of version 0.2.0, python-registry is released under the Apache 2.0 license.
82Before that, python-registry was released under the GPLv3.
83
84
85Sources
86-------
87Nearly all structure definitions used in python-registry
88came from one of two sources:
891) WinReg.txt, by B.H., which may be accessed at:
90   http://pogostick.net/~pnh/ntpasswd/WinReg.txt
912) The Windows NT Registry File Format version 0.4, by
92   Timothy D. Morgan, which may be accessed at:
93   https://docs.google.com/viewer?url=http%3A%2F%2Fsentinelchicken.com%2Fdata%2FTheWindowsNTRegistryFileFormat.pdf
94Copies of these resources are included in the
95`documentation/` directory of the python-registry source.
96
97
98The source directory for python-registry contains a `sample/`
99subdirectory that contains small programs that use python-registry.
100For example, `regview.py` is a read-only clone of Microsoft Window's
101Regedit, implemented in a few hundred lines.
102