Zig 0.17.0-dev (Split by item)

Shortcut keys
?
Show these tips
S
Focus search field
Esc
Clear focus & close tips
U
Jump to source code
↑
Move up in search results
↓
Move down in search results
↵
Go to active search result
This is an example of documentation generated by ZigDoc, an alternative to Zig's built-in Auto Doc feature. See also examples in other modes/formats. The project being documented here (as the example) is the Zig standard library. Private Function

isValidVersion

Private Function
std.zig.WindowsSdk.Installation.isValidVersion
fn isValidVersion(installation: Installation, roots_key: Registry.Key) bool

Check whether this version is enumerated in registry.

Params

File

zig/WindowsSdk.zig:618
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
    fn isValidVersion(installation: Installation, roots_key: Registry.Key) bool {
        var version_buf: [product_version_max_length]u16 = undefined;
        const version_len = std.unicode.wtf8ToWtf16Le(&version_buf, installation.version) catch return false;
        const version = version_buf[0..version_len];
        const options_key_name = "Installed Options";
        const buf_len = product_version_max_length + options_key_name.len + 2;
        var buf: [buf_len]u16 = undefined;
        var query: std.ArrayList(u16) = .initBuffer(&buf);
        query.appendSliceAssumeCapacity(version);
        query.appendAssumeCapacity('\\');
        query.appendSliceAssumeCapacity(L(options_key_name));

        const options_key = roots_key.open(query.items) catch |err| switch (err) {
            error.KeyNotFound => return false,
        };
        defer options_key.close();

        const option_name = comptime switch (builtin.target.cpu.arch) {
            .thumb => "OptionId.DesktopCPParm",
            .aarch64 => "OptionId.DesktopCPParm64",
            .x86 => "OptionId.DesktopCPPx86",
            .x86_64 => "OptionId.DesktopCPPx64",
            else => |tag| @compileError("Windows SDK cannot be detected on architecture " ++ tag),
        };

        const reg_value = options_key.getDword(.{ .name = L(option_name) }) catch return false;
        return (reg_value == 1);
    }