当前位置: 首页>>代码示例>>C++>>正文


C++ wxGetenv函数代码示例

本文整理汇总了C++中wxGetenv函数的典型用法代码示例。如果您正苦于以下问题:C++ wxGetenv函数的具体用法?C++ wxGetenv怎么用?C++ wxGetenv使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了wxGetenv函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: wxGetUserHome

wxString wxGetUserHome( const wxString &user )
{
    struct passwd *who = (struct passwd *) NULL;

    if ( !user )
    {
        wxChar *ptr;

        if ((ptr = wxGetenv(wxT("HOME"))) != NULL)
        {
            return ptr;
        }

        if ((ptr = wxGetenv(wxT("USER"))) != NULL ||
                (ptr = wxGetenv(wxT("LOGNAME"))) != NULL)
        {
            who = getpwnam(wxSafeConvertWX2MB(ptr));
        }

        // make sure the user exists!
        if ( !who )
        {
            who = getpwuid(getuid());
        }
    }
    else
    {
        who = getpwnam (user.mb_str());
    }

    return wxSafeConvertMB2WX(who ? who->pw_dir : 0);
}
开发者ID:ahlekoofe,项目名称:gamekit,代码行数:32,代码来源:utilsunx.cpp

示例2: var

wxString wxSystemOptions::GetOption(const wxString& name)
{
    wxString val;

    int idx = gs_optionNames.Index(name, false);
    if ( idx != wxNOT_FOUND )
    {
        val = gs_optionValues[idx];
    }
    else // not set explicitly
    {
        // look in the environment: first for a variable named "wx_appname_name"
        // which can be set to affect the behaviour or just this application
        // and then for "wx_name" which can be set to change the option globally
        wxString var(name);
        var.Replace(wxT("."), wxT("_"));  // '.'s not allowed in env var names
        var.Replace(wxT("-"), wxT("_"));  // and neither are '-'s

        wxString appname;
        if ( wxTheApp )
            appname = wxTheApp->GetAppName();

        if ( !appname.empty() )
            val = wxGetenv(wxT("wx_") + appname + wxT('_') + var);

        if ( val.empty() )
            val = wxGetenv(wxT("wx_") + var);
    }

    return val;
}
开发者ID:vdm113,项目名称:wxWidgets-ICC-patch,代码行数:31,代码来源:sysopt.cpp

示例3: GetDownloadDir

CLocalPath GetDownloadDir()
{
#ifdef __WXMSW__
	// Old Vista has a profile directory for downloaded files,
	// need to get it using SHGetKnownFolderPath which we need to
	// load dynamically to preserve forward compatibility with the
	// upgrade to Windows XP.
	wxDynamicLibrary lib(_T("shell32.dll"));
	if (lib.IsLoaded() && lib.HasSymbol(_T("SHGetKnownFolderPath"))) {
		tSHGetKnownFolderPath pSHGetKnownFolderPath = (tSHGetKnownFolderPath)lib.GetSymbol(_T("SHGetKnownFolderPath"));

		PWSTR path;
		HRESULT result = pSHGetKnownFolderPath(VISTASHIT_FOLDERID_Downloads, 0, 0, &path);
		if(result == S_OK) {
			wxString dir = path;
			CoTaskMemFree(path);
			return CLocalPath(dir);
		}
	}
#elif !defined(__WXMAC__)
	// Code copied from wx, but for downloads directory.
	// Also, directory is now unescaped.
	{
		wxLogNull logNull;
		wxString homeDir = wxFileName::GetHomeDir();
		wxString configPath;
		if (wxGetenv(wxT("XDG_CONFIG_HOME")))
			configPath = wxGetenv(wxT("XDG_CONFIG_HOME"));
		else
			configPath = homeDir + wxT("/.config");
		wxString dirsFile = configPath + wxT("/user-dirs.dirs");
		if (wxFileExists(dirsFile)) {
			wxTextFile textFile;
			if (textFile.Open(dirsFile)) {
				size_t i;
				for (i = 0; i < textFile.GetLineCount(); i++) {
					wxString line(textFile[i]);
					int pos = line.Find(wxT("XDG_DOWNLOAD_DIR"));
					if (pos != wxNOT_FOUND) {
						wxString value = line.AfterFirst(wxT('='));
						value = ShellUnescape(value);
						if (!value.IsEmpty() && wxDirExists(value))
							return CLocalPath(value);
						else
							break;
					}
				}
			}
		}
	}
#endif
	return CLocalPath(wxStandardPaths::Get().GetDocumentsDir());
}
开发者ID:pappacurds,项目名称:filezilla,代码行数:53,代码来源:file_utils.cpp

示例4: GetDownloadDir

CLocalPath GetDownloadDir()
{
#ifdef __WXMSW__
	// Unfortunately MinGW's import library lacks SHGetKnownFolderPath, even though it has it in its headers.
	wxDynamicLibrary lib(_T("shell32.dll"));
	if (lib.IsLoaded() && lib.HasSymbol(_T("SHGetKnownFolderPath"))) {
		tSHGetKnownFolderPath pSHGetKnownFolderPath = (tSHGetKnownFolderPath)lib.GetSymbol(_T("SHGetKnownFolderPath"));

		PWSTR path;
		HRESULT result = pSHGetKnownFolderPath(FOLDERID_Downloads, 0, 0, &path);
		if(result == S_OK) {
			std::wstring dir = path;
			CoTaskMemFree(path);
			return CLocalPath(dir);
		}
	}
#elif !defined(__WXMAC__)
	// Code copied from wx, but for downloads directory.
	// Also, directory is now unescaped.
	{
		wxLogNull logNull;
		wxString homeDir = wxFileName::GetHomeDir();
		wxString configPath;
		if (wxGetenv(wxT("XDG_CONFIG_HOME"))) {
			configPath = wxGetenv(wxT("XDG_CONFIG_HOME"));
		}
		else {
			configPath = homeDir + wxT("/.config");
		}
		wxString dirsFile = configPath + wxT("/user-dirs.dirs");
		if (wxFileExists(dirsFile)) {
			wxTextFile textFile;
			if (textFile.Open(dirsFile)) {
				size_t i;
				for (i = 0; i < textFile.GetLineCount(); i++) {
					wxString line(textFile[i]);
					int pos = line.Find(wxT("XDG_DOWNLOAD_DIR"));
					if (pos != wxNOT_FOUND) {
						wxString value = line.AfterFirst(wxT('='));
						value = ShellUnescape(value);
						if (!value.empty() && wxDirExists(value))
							return CLocalPath(value.ToStdWstring());
						else
							break;
					}
				}
			}
		}
	}
#endif
	return CLocalPath(wxStandardPaths::Get().GetDocumentsDir().ToStdWstring());
}
开发者ID:zedfoxus,项目名称:filezilla-client,代码行数:52,代码来源:file_utils.cpp

示例5: wxGetHostName

// returns %ComputerName%, or $HOSTNAME, or "host"
//
bool wxGetHostName(wxChar *buf, int n)
{
    const wxChar *host = wxGetenv(wxT("ComputerName"));

    if (!host)
        host = wxGetenv(wxT("HOSTNAME"));

    if (!host)
        host = wxT("host");

    wxStrlcpy(buf, host, n);
    return true;
}
开发者ID:yinglang,项目名称:newton-dynamics,代码行数:15,代码来源:utilsdos.cpp

示例6: wxGetUserId

// returns %UserName%, $USER or just "user"
//
bool wxGetUserId(wxChar *buf, int n)
{
    const wxChar *user = wxGetenv(wxT("UserName"));

    if (!user)
        user = wxGetenv(wxT("USER"));

    if (!user)
        user = wxT("user");

    wxStrlcpy(buf, user, n);
    return true;
}
开发者ID:yinglang,项目名称:newton-dynamics,代码行数:15,代码来源:utilsdos.cpp

示例7: wxGetUserHome

wxChar* wxGetUserHome ( const wxString &rUser )
#endif
{
    wxChar*    zHome;
    wxString   sUser1(rUser);

    wxChar *wxBuffer = new wxChar[256];
#ifndef __EMX__
    if (!sUser1.empty())
    {
        wxChar                      zTmp[64];

        if (wxGetUserId( zTmp
                        ,sizeof(zTmp)/sizeof(char)
                       ))
        {
            // Guests belong in the temp dir
            if (wxStricmp(zTmp, _T("annonymous")) == 0)
            {
                if ((zHome = wxGetenv(_T("TMP"))) != NULL    ||
                    (zHome = wxGetenv(_T("TMPDIR"))) != NULL ||
                    (zHome = wxGetenv(_T("TEMP"))) != NULL)
                    delete[] wxBuffer;
                    return *zHome ? zHome : (wxChar*)_T("\\");
            }
            if (wxStricmp(zTmp, WXSTRINGCAST sUser1) == 0)
                sUser1 = wxEmptyString;
        }
    }
#endif
    if (sUser1.empty())
    {
        if ((zHome = wxGetenv(_T("HOME"))) != NULL)
        {
            wxStrcpy(wxBuffer, zHome);
            wxUnix2DosFilename(wxBuffer);
#if wxUSE_UNICODE
            wxWCharBuffer retBuffer (wxBuffer);
            delete[] wxBuffer;
            return retBuffer;
#else
            wxStrcpy(zHome, wxBuffer);
            delete[] wxBuffer;
            return zHome;
#endif
        }
    }
    delete[] wxBuffer;
    return (wxChar*)wxEmptyString; // No home known!
}
开发者ID:czxxjtu,项目名称:wxPython-1,代码行数:50,代码来源:utils.cpp

示例8: wxHelpControllerBase

wxExtHelpController::wxExtHelpController(wxWindow* parentWindow)
                   : wxHelpControllerBase(parentWindow)
{
   m_MapList = NULL;
   m_NumOfEntries = 0;
   m_BrowserIsNetscape = false;

   wxChar *browser = wxGetenv(WXEXTHELP_ENVVAR_BROWSER);
   if (browser)
   {
      m_BrowserName = browser;
      browser = wxGetenv(WXEXTHELP_ENVVAR_BROWSERISNETSCAPE);
      m_BrowserIsNetscape = browser && (wxAtoi(browser) != 0);
   }
}
开发者ID:EdgarTx,项目名称:wx,代码行数:15,代码来源:helpext.cpp

示例9: wxGetHomeDir

// ---------------------------------------------------------------------------
const wxChar* wxGetHomeDir(
  wxString*                         pStr
)
{
    wxString&                       rStrDir = *pStr;

    // OS/2 has no idea about home,
    // so use the working directory instead.
    // However, we might have a valid HOME directory,
    // as is used on many machines that have unix utilities
    // on them, so we should use that, if available.

    // 256 was taken from os2def.h
#ifndef MAX_PATH
#  define MAX_PATH  256
#endif

    const wxChar *szHome = wxGetenv((wxChar*)"HOME");
    if ( szHome == NULL ) {
      // we're homeless, use current directory.
      rStrDir = wxT(".");
    }
    else
       rStrDir = szHome;

    return rStrDir.c_str();
}
开发者ID:czxxjtu,项目名称:wxPython-1,代码行数:28,代码来源:utils.cpp

示例10: wxGlobalDisplay

PangoContext* wxApp::GetPangoContext()
{
    static PangoContext *s_pangoContext = NULL;
    if ( !s_pangoContext )
    {
        Display *dpy = wxGlobalDisplay();

#ifdef HAVE_PANGO_XFT
        int xscreen = DefaultScreen(dpy);
        static int use_xft = -1;
        if (use_xft == -1)
        {
            wxString val = wxGetenv( L"GDK_USE_XFT" );
            use_xft = val == L"1";
        }

        if (use_xft)
            s_pangoContext = pango_xft_get_context(dpy, xscreen);
        else
#endif // HAVE_PANGO_XFT
            s_pangoContext = pango_x_get_context(dpy);

        if (!PANGO_IS_CONTEXT(s_pangoContext))
        {
            wxLogError( wxT("No pango context.") );
        }
    }

    return s_pangoContext;
}
开发者ID:CustomCardsOnline,项目名称:wxWidgets,代码行数:30,代码来源:app.cpp

示例11: wxGetenv

wxString ConsoleFinder::GetConsoleName()
{
	wxString cmd;
#ifdef __WXMSW__
	cmd = wxGetenv(wxT("COMSPEC"));
	if ( cmd.IsEmpty() ) {
		cmd = wxT("CMD.EXE");
	}
#else //non-windows
	//try to locate the default terminal
	wxString terminal;
	wxString where;
	if (ExeLocator::Locate(wxT("gnome-terminal"), where)) {
		terminal = wxT("gnome-terminal -e ");
	} else if (ExeLocator::Locate(wxT("konsole"), where)) {
		terminal = wxT("konsole");
    } else if (ExeLocator::Locate(wxT("terminal"), where)) {
		terminal = wxT("terminal -e");
    } else if (ExeLocator::Locate(wxT("lxterminal"), where)) {
		terminal = wxT("lxterminal -e");
	} else if (ExeLocator::Locate(wxT("xterm"), where)) {
		terminal = wxT("xterm -e ");
	}

	if (cmd.IsEmpty()) {
		cmd = wxT("xterm -e ");
	}

	cmd = terminal;
#endif
	return cmd;
}
开发者ID:05storm26,项目名称:codelite,代码行数:32,代码来源:consolefinder.cpp

示例12: wxGetHostName

// Get hostname only (without domain name)
bool wxGetHostName(wxChar *WXUNUSED_IN_WINCE(buf),
                   int WXUNUSED_IN_WINCE(maxSize))
{
#if defined(__WXWINCE__)
    // TODO-CE
    return false;
#elif defined(__WIN32__) && !defined(__WXMICROWIN__)
    DWORD nSize = maxSize;
    if ( !::GetComputerName(buf, &nSize) )
    {
        wxLogLastError(wxT("GetComputerName"));

        return false;
    }

    return true;
#else
    wxChar *sysname;
    const wxChar *default_host = wxT("noname");

    if ((sysname = wxGetenv(wxT("SYSTEM_NAME"))) == NULL) {
        GetProfileString(WX_SECTION, eHOSTNAME, default_host, buf, maxSize - 1);
    } else
        wxStrncpy(buf, sysname, maxSize - 1);
    buf[maxSize] = wxT('\0');
    return *buf ? true : false;
#endif
}
开发者ID:252525fb,项目名称:rpcs3,代码行数:29,代码来源:utils.cpp

示例13: wxGetenv

bool ProcUtils::Shell()
{
	wxString cmd;
#ifdef __WXMSW__
	wxChar *shell = wxGetenv(wxT("COMSPEC"));
	if ( !shell ) {
		shell = (wxChar*) wxT("\\COMMAND.COM");
	}

	// just the shell
	cmd = shell;
#elif defined(__WXMAC__)
	wxString path = wxGetCwd();
	cmd = wxString( wxT("osascript -e 'tell application \"Terminal\"' -e 'activate' -e 'do script with command \"cd ") + path + wxT("\"' -e 'end tell'") );
#else //non-windows
	//try to locate the default terminal
	wxString terminal;
	wxString where;
	if (Locate(wxT("gnome-terminal"), where)) {
		terminal = where;
	} else if (Locate(wxT("konsole"), where)) {
		terminal = where;
	} else if (Locate(wxT("xterm"), where)) {
		terminal = where;
	}
	cmd = terminal;
#endif
	return wxExecute(cmd, wxEXEC_ASYNC) != 0;
}
开发者ID:RVictor,项目名称:EmbeddedLite,代码行数:29,代码来源:procutils.cpp

示例14: wxShell

// Execute a program in an Interactive Shell
bool wxShell(const wxString& command)
{
    wxString cmd;

#ifdef __WXWINCE__
    cmd = command;
#else
    wxChar *shell = wxGetenv(wxT("COMSPEC"));
    if ( !shell )
        shell = (wxChar*) wxT("\\COMMAND.COM");

    if ( !command )
    {
        // just the shell
        cmd = shell;
    }
    else
    {
        // pass the command to execute to the command processor
        cmd.Printf(wxT("%s /c %s"), shell, command.c_str());
    }
#endif

    return wxExecute(cmd, wxEXEC_SYNC) == 0;
}
开发者ID:252525fb,项目名称:rpcs3,代码行数:26,代码来源:utils.cpp

示例15: wxGetenv

bool TerminalEmulator::ExecuteNoConsole(const wxString& commandToRun, const wxString& workingDirectory)
{
    if(m_process) {
        // another process is running
        return false;
    }

    wxString command;
#ifdef __WXMSW__
    wxString shell = wxGetenv("COMSPEC");
    if(shell.IsEmpty()) { shell = "CMD"; }

    command << shell << wxT(" /c \"");
    command << commandToRun << wxT("\"");

#else
    wxString tmpCmd = commandToRun;
    command << "/bin/sh -c '";
    // escape any single quoutes
    tmpCmd.Replace("'", "\\'");
    command << tmpCmd << "'";
#endif
    clLogMessage("TerminalEmulator::ExecuteNoConsole: " + command);
    m_process = ::CreateAsyncProcess(this, command, IProcessCreateWithHiddenConsole, workingDirectory);
    return m_process != NULL;
}
开发者ID:eranif,项目名称:codelite,代码行数:26,代码来源:TerminalEmulator.cpp


注:本文中的wxGetenv函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。