X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/1fb454751dc73befe13142c56778a3dcfcaed561..bdce924e121ae7340a0106682dc5bc672d56f59e:/src/msw/utils.cpp diff --git a/src/msw/utils.cpp b/src/msw/utils.cpp index 0c647be3b5..3d64ac1705 100644 --- a/src/msw/utils.cpp +++ b/src/msw/utils.cpp @@ -457,6 +457,29 @@ bool wxDirExists(const wxString& dir) #endif // Win32/16 } +// ---------------------------------------------------------------------------- +// env vars +// ---------------------------------------------------------------------------- + +bool wxGetEnv(const wxString& var, wxString *value) +{ + // first get the size of the buffer + DWORD dwRet = ::GetEnvironmentVariable(var, NULL, 0); + if ( !dwRet ) + { + // this means that there is no such variable + return FALSE; + } + + if ( value ) + { + (void)::GetEnvironmentVariable(var, value->GetWriteBuf(dwRet), dwRet); + value->UngetWriteBuf(); + } + + return TRUE; +} + bool wxSetEnv(const wxString& var, const wxChar *value) { // some compilers have putenv() or _putenv() or _wputenv() but it's better