Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
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 Go to next message
koldo is currently offline  koldo
Messages: 3355
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 406 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 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
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

Re: More small gems [message #18727 is a reply to message #18725] Sat, 18 October 2008 20:07 Go to previous message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
Thank you

I am really happy to help.

Best regards
Koldo


Best regards
Iñaki
Previous Topic: DirectoryUp doesn't seem to work.
Next Topic: Small Upp gems. Native icons in TreeCtrl
Goto Forum:
  


Current Time: Fri Mar 29 09:17:48 CET 2024

Total time taken to generate the page: 0.01220 seconds