Home » Extra libraries, Code snippets, applications etc. » U++ users applications in progress and useful code snippets, including reference examples! » More small gems
Re: More small gems [message #18725 is a reply to message #18504] |
Sat, 18 October 2008 19:48   |
 |
mirek
Messages: 14261 Registered: November 2005
|
Ultimate Member |
|
|
Thanks, adapted to Core:
String GetEnv(const char *id)
{
return FromSystemCharset(getenv(id));
}
String GetComputerName()
{
char temp[256];
*temp = 0;
#if defined(PLATFORM_WIN32)
dword w = 255;
::GetComputerNameA(temp, &w);
#else
gethostname(temp, sizeof(temp));
#endif
return FromSystemCharset(temp);
}
String GetUserName()
{
char temp[256];
*temp = 0;
#if defined(PLATFORM_WIN32)
dword w = 255;
::GetUserNameA(temp, &w);
return FromSystemCharset(temp);
#else
return Nvl(GetEnv("USER"), "boot");
#endif
}
String GetDesktopManager()
{
#if defined(PLATFORM_WIN32) && !defined(PLATFORM_WINCE)
return "windows";
#endif
#ifdef PLATFORM_POSIX
if(GetEnv("GNOME_DESKTOP_SESSION_ID").GetCount())
return "gnome";
if(GetEnv("KDE_FULL_SESSION").GetCount() || GetEnv("KDEDIR").GetCount())
return "kde";
return GetEnv("DESKTOP_SESSION");
#endif
}
(Note the change in GetDektoManager return values...)
Mirek
[Updated on: Sat, 18 October 2008 19:49] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Fri Jun 06 21:11:23 CEST 2025
Total time taken to generate the page: 0.04350 seconds
|