simple_registry

Windows Registry Access for Eiffel

Foundation Layer v1.0.0 MIT

Overview

simple_registry provides safe, SCOOP-compatible access to the Windows Registry from Eiffel applications. It wraps the Win32 Registry API functions through a clean C interface, enabling registry operations without threading complications.

The library supports reading and writing string, integer, and binary values across all major registry hives (HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE, etc.), with proper error handling and resource cleanup.

Part of the simple_* ecosystem of focused, single-purpose Eiffel libraries.

Quick Start

Installation

<library name="simple_registry" location="$SIMPLE_EIFFEL/simple_registry/simple_registry.ecf"/>

Read a String Value

local
    reg: SIMPLE_REGISTRY
    value: detachable STRING_8
do
    create reg.make

    -- Read from HKEY_CURRENT_USER
    value := reg.read_string (reg.HKCU, "Software\MyApp", "Username")

    if attached value as v then
        print ("Username: " + v)
    end

    reg.close
end

Write Values

local
    reg: SIMPLE_REGISTRY
do
    create reg.make

    -- Write a string value
    reg.write_string (reg.HKCU, "Software\MyApp", "Username", "JohnDoe")

    -- Write an integer value
    reg.write_integer (reg.HKCU, "Software\MyApp", "LaunchCount", 42)

    if reg.last_write_succeeded then
        print ("Values written successfully")
    end

    reg.close
end

Features

Read Values

Query string, integer (DWORD), and binary registry values

Write Values

Create or update string and integer values

Delete Values

Remove specific values from registry keys

Key Management

Open, create, and delete registry keys

Registry Hives

ConstantHive
HKCUHKEY_CURRENT_USER
HKLMHKEY_LOCAL_MACHINE
HKCRHKEY_CLASSES_ROOT
HKUHKEY_USERS
HKCCHKEY_CURRENT_CONFIG

API Reference

read_string (a_hive, a_subkey, a_value_name): detachable STRING_8

value := reg.read_string (reg.HKCU, "Software\MyApp", "Setting")

Read REG_SZ value from registry. Returns Void if not found.

read_integer (a_hive, a_subkey, a_value_name): INTEGER

count := reg.read_integer (reg.HKCU, "Software\MyApp", "Count")

Read REG_DWORD value from registry.

write_string (a_hive, a_subkey, a_value_name, a_value)

reg.write_string (reg.HKCU, "Software\MyApp", "Name", "Value")

Write REG_SZ value to registry.

write_integer (a_hive, a_subkey, a_value_name, a_value)

reg.write_integer (reg.HKCU, "Software\MyApp", "Count", 42)

Write REG_DWORD value to registry.

Status Queries

FeatureDescription
last_read_succeededDid the last read operation succeed?
last_write_succeededDid the last write operation succeed?
last_error_codeWindows error code from last failed operation