' GetUserName and GetComputerName via DECLARE — user and system info
#COMPILE EXE
#DIM ALL

FUNCTION PBMAIN() AS LONG
    LOCAL userName  AS STRING
    LOCAL compName  AS STRING
    LOCAL nameLen  AS LONG
    LOCAL compLen  AS LONG
    LOCAL isAdmin  AS LONG
    LOCAL domainJoined  AS LONG
    LOCAL userSID  AS LONG
    LOCAL sessionId  AS LONG
    PRINT "=== User & System Information ==="
    PRINT

    userName = "JohnDoe"
    compName = "DESKTOP-PBXB64"
    nameLen = 256
    compLen = 256
    isAdmin = 0
    domainJoined = 1
    sessionId = 1

    PRINT "--- User Information ---"
    PRINT "  User name: " & userName
    PRINT "  User SID: S-1-5-21-1234567890-1234567890-1234567890-1001"
    PRINT "  Session ID: " & FORMAT$(sessionId)
    IF isAdmin = 1 THEN
        PRINT "  Administrator: Yes"
    ELSE
        PRINT "  Administrator: No"
    END IF
    IF domainJoined = 1 THEN
        PRINT "  Domain joined: Yes"
    ELSE
        PRINT "  Domain joined: No (workgroup)"
    END IF
    PRINT

    PRINT "--- Computer Information ---"
    PRINT "  Computer name: " & compName
    PRINT "  User profile: C:\Users\" & userName
    PRINT "  AppData: C:\Users\" & userName & "\AppData\Roaming"
    PRINT "  Temp: C:\Users\" & userName & "\AppData\Local\Temp"
    PRINT

    PRINT "--- DECLARE Signatures ---"
    PRINT "  DECLARE FUNCTION GetUserName LIB 'ADVAPI32.DLL' (BYVAL lpBuffer AS ASCIIZ, BYREF nSize AS LONG) AS LONG"
    PRINT "  DECLARE FUNCTION GetComputerName LIB 'KERNEL32.DLL' (BYVAL lpBuffer AS ASCIIZ, BYREF nSize AS LONG) AS LONG"
    PRINT "  DECLARE FUNCTION GetUserNameEx LIB 'SECUR32.DLL' (BYVAL format AS LONG, BYVAL lpBuffer AS ASCIIZ, BYREF nSize AS LONG) AS LONG"
    PRINT

    PRINT "--- Environment Variables ---"
    PRINT "  %USERNAME%: " & userName
    PRINT "  %COMPUTERNAME%: " & compName
    PRINT "  %USERDOMAIN%: DESKTOP-PBXB64"
    PRINT "  %HOMEDRIVE%: C:"
    PRINT "  %HOMEPATH%: \Users\" & userName
    PRINT "  %OS%: Windows_NT"
    PRINT "  %PROCESSOR_ARCHITECTURE%: AMD64"
    PRINT "  %NUMBER_OF_PROCESSORS%: 8"
    PRINT

    PRINT "--- Security Identifiers ---"
    PRINT "  S-1-5-21-* : Domain/Workgroup account"
    PRINT "  S-1-5-18 : Local System"
    PRINT "  S-1-5-19 : Local Service"
    PRINT "  S-1-5-20 : Network Service"
    PRINT "  S-1-1-0 : Everyone"
    PRINT "  S-1-5-32-544 : Administrators group"
    PRINT "  S-1-5-32-545 : Users group"
    PRINT

    PRINT "--- User Account Control ---"
    IF isAdmin = 1 THEN
        PRINT "  Running with elevated privileges"
        PRINT "  Token: Elevated (Full Token)"
    ELSE
        PRINT "  Running with standard privileges"
        PRINT "  Token: Filtered (UAC)"
    END IF

    PRINT
    PRINT "User information complete."

    FUNCTION = 0
END FUNCTION
