From 2aad589775cf8ef80cf40f1637eddcb9a8b526f8 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 12 Oct 2000 23:33:44 +0000 Subject: [PATCH] partial fix for REG_EXPAND_SZ values git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_2_BRANCH@8540 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/registry.cpp | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/msw/registry.cpp b/src/msw/registry.cpp index a761867e7d..369db0706e 100644 --- a/src/msw/registry.cpp +++ b/src/msw/registry.cpp @@ -27,7 +27,6 @@ #include "wx/string.h" #include "wx/intl.h" #include "wx/log.h" -#include "wx/config.h" // for wxExpandEnvVars #ifndef __WIN16__ @@ -846,6 +845,30 @@ bool wxRegKey::QueryValue(const wxChar *szValue, wxString& strValue) const pBuf, &dwSize); strValue.UngetWriteBuf(); + + // always expand the var expansions in the string + if ( dwType == REG_EXPAND_SZ ) + { + DWORD dwExpSize = ::ExpandEnvironmentStrings(strValue, NULL, 0); + bool ok = dwExpSize != 0; + if ( ok ) + { + wxString strExpValue; + ok = ::ExpandEnvironmentStrings + ( + strValue, + strExpValue.GetWriteBuf(dwExpSize), + dwExpSize + ) != 0; + strExpValue.UngetWriteBuf(); + strValue = strExpValue; + } + + if ( !ok ) + { + wxLogLastError(_T("ExpandEnvironmentStrings")); + } + } } if ( m_dwLastError == ERROR_SUCCESS ) {