Home » Extra libraries, Code snippets, applications etc. » U++ users applications in progress and useful code snippets, including reference examples! » More small gems
More small gems [message #18504] |
Sat, 04 October 2008 15:24 |
|
koldo
Messages: 3394 Registered: August 2008
|
Senior Veteran |
|
|
Dear all
Here I enclose you more functions that I have prepared taking code from Upp itself, but that are not declared. There is also something from myself:
String GetComputerName()
- Returns computer name
String GetUserName()
- Returns user name
String GetEnvironmentVariable(const char *str)
- Return the environment variable
String GetDesktopManager()
- Returns Windows, Gnome, Kde or Unknown
Sorry: I have only tested GetDesktopManager() in Ubuntu and Windows. Please check it in other desktop like Kde.
Best regards
Koldo
-
Attachment: Funs.cpp
(Size: 1.19KB, Downloaded 450 times)
Best regards
Iñaki
[Updated on: Sun, 05 October 2008 09:33] Report message to a moderator
|
|
|
Re: More small gems [message #18725 is a reply to message #18504] |
Sat, 18 October 2008 19:48 |
|
mirek
Messages: 14038 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 Sep 20 04:07:04 CEST 2024
Total time taken to generate the page: 0.02920 seconds
|