' GetVersionEx simulation for Windows version detection
#COMPILE EXE
#DIM ALL

FUNCTION PBMAIN() AS LONG
    LOCAL major  AS LONG
    LOCAL minor  AS LONG
    LOCAL build  AS LONG
    LOCAL spMajor  AS LONG
    LOCAL spMinor  AS LONG
    LOCAL platformId  AS LONG
    LOCAL isServer  AS LONG
    LOCAL is64Bit  AS LONG
    LOCAL versionStr  AS STRING
    LOCAL editionStr  AS STRING
    PRINT "=== Windows Version Information ==="
    PRINT

    major = 10
    minor = 0
    build = 22621
    spMajor = 0
    spMinor = 0
    platformId = 2
    isServer = 0
    is64Bit = 1

    PRINT "--- Version Numbers ---"
    PRINT "  Major version: " & FORMAT$(major)
    PRINT "  Minor version: " & FORMAT$(minor)
    PRINT "  Build number: " & FORMAT$(build)
    PRINT "  Service pack: " & FORMAT$(spMajor) & "." & FORMAT$(spMinor)
    PRINT "  Platform ID: " & FORMAT$(platformId)
    PRINT

    IF major = 10 AND minor = 0 AND build >= 22000 THEN
        versionStr = "Windows 11"
    ELSE
        IF major = 10 AND minor = 0 THEN
            versionStr = "Windows 10"
        ELSE
            IF major = 6 AND minor = 3 THEN
                versionStr = "Windows 8.1"
            ELSE
                IF major = 6 AND minor = 2 THEN
                    versionStr = "Windows 8"
                ELSE
                    IF major = 6 AND minor = 1 THEN
                        versionStr = "Windows 7"
                    ELSE
                        versionStr = "Unknown Windows"
                    END IF
                END IF
            END IF
        END IF
    END IF

    editionStr = "Pro"
    IF major = 10 AND minor = 0 AND build >= 22000 THEN
        editionStr = "Windows 11 Pro"
    ELSE
        editionStr = "Windows 10 Pro"
    END IF

    PRINT "--- Operating System ---"
    PRINT "  Version: " & versionStr & " (build " & FORMAT$(build) & ")"
    PRINT "  Edition: " & editionStr
    IF isServer = 1 THEN
        PRINT "  Type: Server"
    ELSE
        PRINT "  Type: Workstation"
    END IF
    IF is64Bit = 1 THEN
        PRINT "  Architecture: 64-bit (x64)"
    ELSE
        PRINT "  Architecture: 32-bit (x86)"
    END IF
    PRINT

    PRINT "--- OS Version History ---"
    PRINT "  Windows 11:   10.0.22000+"
    PRINT "  Windows 10:   10.0.10240-19045"
    PRINT "  Windows 8.1:  6.3.9600"
    PRINT "  Windows 8:    6.2.9200"
    PRINT "  Windows 7:    6.1.7601"
    PRINT "  Windows Vista: 6.0.6002"
    PRINT "  Windows XP:   5.1.2600"
    PRINT

    PRINT "--- DECLARE Signatures ---"
    PRINT "  TYPE OSVERSIONINFOEX"
    PRINT "    dwOSVersionInfoSize AS LONG"
    PRINT "    dwMajorVersion AS LONG"
    PRINT "    dwMinorVersion AS LONG"
    PRINT "    dwBuildNumber AS LONG"
    PRINT "    dwPlatformId AS LONG"
    PRINT "    szCSDVersion AS STRING"
    PRINT "    wServicePackMajor AS INTEGER"
    PRINT "    wServicePackMinor AS INTEGER"
    PRINT "    wSuiteMask AS INTEGER"
    PRINT "    wProductType AS BYTE"
    PRINT "    wReserved AS BYTE"
    PRINT "  END TYPE"
    PRINT

    PRINT "--- Suite Mask ---"
    PRINT "  VER_SUITE_SINGLEUSERTS = 256"
    PRINT "  VER_SUITE_DATACENTER = 512"
    PRINT "  VER_SUITE_ENTERPRISE = 2"
    PRINT "  Current mask: 256 (Terminal Services)"

    PRINT
    PRINT "Version information complete."

    FUNCTION = 0
END FUNCTION
