I know Windows stores the user id in an environment variable, but you shouldn't depend on it for security reasons since it can be overwritten by any application.