
#include "system_util.h"

using namespace std;

const unsigned int BUFFER_SIZE = 1024;

std::wstring getUserName()
{
	wstring userName;
	wchar_t szUserName[BUFFER_SIZE];
	DWORD userNameBufferSize = BUFFER_SIZE;

	if ( GetUserNameW( szUserName, &userNameBufferSize ) == false )
	{
		throw runtime_error("获取操作系统用户名失败！");
	}

	if ( userNameBufferSize != 0 )
	{
		userName = szUserName;
	}

	return userName;
}
