enumstd.Target.Os.WindowsVersion[src]

Fields

nt4 = 0x04000000
win2k = 0x05000000
xp = 0x05010000
ws2003 = 0x05020000
vista = 0x06000000
win7 = 0x06010000
win8 = 0x06020000
win8_1 = 0x06030000
win10 = 0x0A000000
win10_th2 = 0x0A000001
win10_rs1 = 0x0A000002
win10_rs2 = 0x0A000003
win10_rs3 = 0x0A000004
win10_rs4 = 0x0A000005
win10_rs5 = 0x0A000006
win10_19h1 = 0x0A000007
win10_vb = 0x0A000008
win10_mn = 0x0A000009
win10_fe = 0x0A00000A
win10_co = 0x0A00000B
win10_ni = 0x0A00000C
win10_cu = 0x0A00000D
win11_zn = 0x0A00000E
win11_ga = 0x0A00000F
win11_ge = 0x0A000010
win11_dt = 0x0A000011
_

Values

Constantlatest[src]

Latest Windows version that the Zig Standard Library is aware of

Source Code

Source code
pub const latest = WindowsVersion.win11_dt

Constantknown_win10_build_numbers[src]

Compared against build numbers reported by the runtime to distinguish win10 versions, where 0x0A000000 + index corresponds to the WindowsVersion u32 value.

Source Code

Source code
pub const known_win10_build_numbers = [_]u32{
    10240, //win10 aka win10_th1
    10586, //win10_th2
    14393, //win10_rs1
    15063, //win10_rs2
    16299, //win10_rs3
    17134, //win10_rs4
    17763, //win10_rs5
    18362, //win10_19h1
    18363, //win10_vb aka win10_19h2
    19041, //win10_mn aka win10_20h1
    19042, //win10_fe aka win10_20h2
    19043, //win10_co aka win10_21h1
    19044, //win10_ni aka win10_21h2
    19045, //win10_cu aka win10_22h2
    22000, //win11_zn aka win11_21h2
    22621, //win11_ga aka win11_22h2
    22631, //win11_ge aka win11_23h2
    26100, //win11_dt aka win11_24h2
}

Functions

FunctionisAtLeast[src]

pub inline fn isAtLeast(ver: WindowsVersion, min_ver: WindowsVersion) bool

Returns whether the first version ver is newer (greater) than or equal to the second version ver.

Parameters

Source Code

Source code
pub inline fn isAtLeast(ver: WindowsVersion, min_ver: WindowsVersion) bool {
    return @intFromEnum(ver) >= @intFromEnum(min_ver);
}

Functionparse[src]

pub fn parse(str: []const u8) !WindowsVersion

Parameters

str: []const u8

Source Code

Source code
pub fn parse(str: []const u8) !WindowsVersion {
    return std.meta.stringToEnum(WindowsVersion, str) orelse
        @enumFromInt(std.fmt.parseInt(u32, str, 0) catch
            return error.InvalidOperatingSystemVersion);
}

Functionformat[src]

pub fn format( ver: WindowsVersion, comptime fmt_str: []const u8, _: std.fmt.FormatOptions, writer: anytype, ) @TypeOf(writer).Error!void

This function is defined to serialize a Zig source code representation of this type, that, when parsed, will deserialize into the same data.

Parameters

fmt_str: []const u8

Source Code

Source code
pub fn format(
    ver: WindowsVersion,
    comptime fmt_str: []const u8,
    _: std.fmt.FormatOptions,
    writer: anytype,
) @TypeOf(writer).Error!void {
    const maybe_name = std.enums.tagName(WindowsVersion, ver);
    if (comptime std.mem.eql(u8, fmt_str, "s")) {
        if (maybe_name) |name|
            try writer.print(".{s}", .{name})
        else
            try writer.print(".{d}", .{@intFromEnum(ver)});
    } else if (comptime std.mem.eql(u8, fmt_str, "c")) {
        if (maybe_name) |name|
            try writer.print(".{s}", .{name})
        else
            try writer.print("@enumFromInt(0x{X:0>8})", .{@intFromEnum(ver)});
    } else if (fmt_str.len == 0) {
        if (maybe_name) |name|
            try writer.print("WindowsVersion.{s}", .{name})
        else
            try writer.print("WindowsVersion(0x{X:0>8})", .{@intFromEnum(ver)});
    } else std.fmt.invalidFmtError(fmt_str, ver);
}

Source Code

Source code
pub const WindowsVersion = enum(u32) {
    nt4 = 0x04000000,
    win2k = 0x05000000,
    xp = 0x05010000,
    ws2003 = 0x05020000,
    vista = 0x06000000,
    win7 = 0x06010000,
    win8 = 0x06020000,
    win8_1 = 0x06030000,
    win10 = 0x0A000000, //aka win10_th1
    win10_th2 = 0x0A000001,
    win10_rs1 = 0x0A000002,
    win10_rs2 = 0x0A000003,
    win10_rs3 = 0x0A000004,
    win10_rs4 = 0x0A000005,
    win10_rs5 = 0x0A000006,
    win10_19h1 = 0x0A000007,
    win10_vb = 0x0A000008, //aka win10_19h2
    win10_mn = 0x0A000009, //aka win10_20h1
    win10_fe = 0x0A00000A, //aka win10_20h2
    win10_co = 0x0A00000B, //aka win10_21h1
    win10_ni = 0x0A00000C, //aka win10_21h2
    win10_cu = 0x0A00000D, //aka win10_22h2
    win11_zn = 0x0A00000E, //aka win11_21h2
    win11_ga = 0x0A00000F, //aka win11_22h2
    win11_ge = 0x0A000010, //aka win11_23h2
    win11_dt = 0x0A000011, //aka win11_24h2
    _,

    /// Latest Windows version that the Zig Standard Library is aware of
    pub const latest = WindowsVersion.win11_dt;

    /// Compared against build numbers reported by the runtime to distinguish win10 versions,
    /// where 0x0A000000 + index corresponds to the WindowsVersion u32 value.
    pub const known_win10_build_numbers = [_]u32{
        10240, //win10 aka win10_th1
        10586, //win10_th2
        14393, //win10_rs1
        15063, //win10_rs2
        16299, //win10_rs3
        17134, //win10_rs4
        17763, //win10_rs5
        18362, //win10_19h1
        18363, //win10_vb aka win10_19h2
        19041, //win10_mn aka win10_20h1
        19042, //win10_fe aka win10_20h2
        19043, //win10_co aka win10_21h1
        19044, //win10_ni aka win10_21h2
        19045, //win10_cu aka win10_22h2
        22000, //win11_zn aka win11_21h2
        22621, //win11_ga aka win11_22h2
        22631, //win11_ge aka win11_23h2
        26100, //win11_dt aka win11_24h2
    };

    /// Returns whether the first version `ver` is newer (greater) than or equal to the second version `ver`.
    pub inline fn isAtLeast(ver: WindowsVersion, min_ver: WindowsVersion) bool {
        return @intFromEnum(ver) >= @intFromEnum(min_ver);
    }

    pub const Range = struct {
        min: WindowsVersion,
        max: WindowsVersion,

        pub inline fn includesVersion(range: Range, ver: WindowsVersion) bool {
            return @intFromEnum(ver) >= @intFromEnum(range.min) and
                @intFromEnum(ver) <= @intFromEnum(range.max);
        }

        /// Checks if system is guaranteed to be at least `version` or older than `version`.
        /// Returns `null` if a runtime check is required.
        pub inline fn isAtLeast(range: Range, min_ver: WindowsVersion) ?bool {
            if (@intFromEnum(range.min) >= @intFromEnum(min_ver)) return true;
            if (@intFromEnum(range.max) < @intFromEnum(min_ver)) return false;
            return null;
        }
    };

    pub fn parse(str: []const u8) !WindowsVersion {
        return std.meta.stringToEnum(WindowsVersion, str) orelse
            @enumFromInt(std.fmt.parseInt(u32, str, 0) catch
                return error.InvalidOperatingSystemVersion);
    }

    /// This function is defined to serialize a Zig source code representation of this
    /// type, that, when parsed, will deserialize into the same data.
    pub fn format(
        ver: WindowsVersion,
        comptime fmt_str: []const u8,
        _: std.fmt.FormatOptions,
        writer: anytype,
    ) @TypeOf(writer).Error!void {
        const maybe_name = std.enums.tagName(WindowsVersion, ver);
        if (comptime std.mem.eql(u8, fmt_str, "s")) {
            if (maybe_name) |name|
                try writer.print(".{s}", .{name})
            else
                try writer.print(".{d}", .{@intFromEnum(ver)});
        } else if (comptime std.mem.eql(u8, fmt_str, "c")) {
            if (maybe_name) |name|
                try writer.print(".{s}", .{name})
            else
                try writer.print("@enumFromInt(0x{X:0>8})", .{@intFromEnum(ver)});
        } else if (fmt_str.len == 0) {
            if (maybe_name) |name|
                try writer.print("WindowsVersion.{s}", .{name})
            else
                try writer.print("WindowsVersion(0x{X:0>8})", .{@intFromEnum(ver)});
        } else std.fmt.invalidFmtError(fmt_str, ver);
    }
}