Skip to content

Registry Key

RegistryKey

Bases: BaseModel

Represents a registry key.

References

export_reg

export_reg(location: RegistryPath) -> Generator[str]

Export the Context Menu as a .reg file format.

Example
[HKEY_LOCAL_MACHINE\Software\Classes\*\shell\ConvertVideo]
"MUIVerb"="Convert mp4..."
"SubCommands"=""

Yields:

Type Description
Generator[str]

Lines of the .reg file.

References
Source code in context_menu_toolkit/registry/registry_structs/registry_key.py
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
def export_reg(self, location: RegistryPath) -> Generator[str]:
    r"""Export the Context Menu as a .reg file format.

    Example:
        ```python3
        [HKEY_LOCAL_MACHINE\Software\Classes\*\shell\ConvertVideo]
        "MUIVerb"="Convert mp4..."
        "SubCommands"=""
        ```

    Yields:
        Lines of the .reg file.

    References:
        [^1]: <https://support.microsoft.com/en-us/topic/how-to-add-modify-or-delete-registry-subkeys-and-values-by-using-a-reg-file-9c7f37cf-a5e9-e1cd-c4fa-2a26218a1a23>.
    """
    yield f"[{location / self.name}]"
    for value in self.values:
        yield value.export_reg()

    yield ""
    for subkey in self.subkeys:
        yield from subkey.export_reg(location / self.name)