Common function to get user name for Windows and Linux

A general discussion forum.
lokesh16
Posts: 1
Joined: 04 Sep 2013, 08:09

Common function to get user name for Windows and Linux

Postby lokesh16 » 04 Sep 2013, 08:45

Hello,

I've written following code to get username for Windows and Linux.

#if TARGET_WINDOWS
TCHAR userName[255]= _T("");
DWORD size = 255;

GetUserName(userName, &size);
sysTmpPath = sysTmpPath + L"vmware-" + userName;
#else
char userName[255];
size_t size = 255;

getlogin_r(userName,size);
sysTmpPath = sysTmpPath + L"vmware-" + std::wstring(userName,userName+strlen(userName));
#endif

I would like to know, Is there any common function in POCO or BOOST to get username for Windows and Linux? Which will handle the OS.

Regards
Lokesh

Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 1 guest

cron