o utilizzi l'API GetEnvironmentVariable() (cerca su google)

oppure, più semplicemente

system("ECHO %USERNAME%"); // utilizzi il DOS.