@echo off
chcp 65001 >nul
setlocal EnableDelayedExpansion

set "VCVARS=C:\Program Files (x86)\Microsoft Visual Studio\18\BuildTools\VC\Auxiliary\Build\vcvars64.bat"

if not exist "!VCVARS!" (
    echo [ERROR] MSVC Build Tools not found at !VCVARS!
    echo Please change the VCVARS path in build.bat to match your VS installation.
    exit /b 1
)

call "!VCVARS!"

set "EDUWIN=D:\XTU\c-train\eduwin"

echo [BUILD] Compiling network_info_demo.exe...
cl /nologo /W3 /utf-8 /std:c17 /I"%EDUWIN%\include" network_info_demo.c /Fe:network_info_demo.exe /link "%EDUWIN%\lib\eduwin.lib" user32.lib kernel32.lib gdi32.lib gdiplus.lib comctl32.lib comdlg32.lib shell32.lib winmm.lib ole32.lib oleaut32.lib version.lib advapi32.lib

if %errorlevel%==0 (
    echo [OK] network_info_demo.exe created.
) else (
    echo [ERROR] Build failed.
    pause
    exit /b 1
)
