// - add high level functions (RegisterOleServer, ...)
///////////////////////////////////////////////////////////////////////////////
-#ifdef __GNUG__
+#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma implementation "registry.h"
#endif
#define WIN32_LEAN_AND_MEAN
*/
-#include <windows.h>
+#include "wx/msw/wrapwin.h"
#ifdef __WXWINCE__
#include "wx/msw/private.h"
// useful for Windows programmers: makes somewhat more clear all these zeroes
// being passed to Windows APIs
-#define RESERVED (NULL)
+#define RESERVED (0)
// ----------------------------------------------------------------------------
// macros
// opens key (it's not an error to call Open() on an already opened key)
bool wxRegKey::Open()
{
- if ( IsOpened() )
- return TRUE;
+ if ( IsOpened() )
+ return TRUE;
+
+ HKEY tmpKey;
+ m_dwLastError = ::RegOpenKeyEx
+ (
+ (HKEY) m_hRootKey,
+ m_strKey,
+ RESERVED,
+ KEY_ALL_ACCESS,
+ &tmpKey
+ );
+
+ if ( m_dwLastError != ERROR_SUCCESS )
+ {
+ wxLogSysError(m_dwLastError, _("Can't open registry key '%s'"),
+ GetName().c_str());
+ return FALSE;
+ }
- HKEY tmpKey;
- m_dwLastError = RegOpenKeyEx((HKEY) m_hRootKey, m_strKey,
- 0, 0, &tmpKey);
- if ( m_dwLastError != ERROR_SUCCESS ) {
- wxLogSysError(m_dwLastError, _("Can't open registry key '%s'"),
- GetName().c_str());
- return FALSE;
- }
- else
- {
m_hKey = (WXHKEY) tmpKey;
return TRUE;
- }
}
// creates key, failing if it exists and !bOkIfExists
bool wxRegKey::Create(bool bOkIfExists)
{
// check for existence only if asked (i.e. order is important!)
- if ( !bOkIfExists && Exists() ) {
+ if ( !bOkIfExists && Exists() )
return FALSE;
- }
if ( IsOpened() )
return TRUE;
strValue.Empty();
}
else {
- RegString pBuf = (RegString)strValue.GetWriteBuf(dwSize);
m_dwLastError = RegQueryValueEx((HKEY) m_hKey,
WXSTRINGCAST szValue,
RESERVED,
&dwType,
- pBuf,
+ (RegString)(wxChar*)wxStringBuffer(strValue, dwSize),
&dwSize);
- strValue.UngetWriteBuf();
// expand the var expansions in the string unless disabled
#ifndef __WXWINCE__
ok = ::ExpandEnvironmentStrings
(
strValue,
- strExpValue.GetWriteBuf(dwExpSize),
+ wxStringBuffer(strExpValue, dwExpSize),
dwExpSize
) != 0;
- strExpValue.UngetWriteBuf();
strValue = strExpValue;
}
bool KeyExists(WXHKEY hRootKey, const wxChar *szKey)
{
- // don't close this key itself for the case of empty szKey!
- if ( wxIsEmpty(szKey) )
- return TRUE;
+ // don't close this key itself for the case of empty szKey!
+ if ( wxIsEmpty(szKey) )
+ return TRUE;
+
+ HKEY hkeyDummy;
+ if ( ::RegOpenKeyEx
+ (
+ (HKEY)hRootKey,
+ szKey,
+ RESERVED,
+ KEY_ALL_ACCESS,
+ &hkeyDummy
+ ) == ERROR_SUCCESS )
+ {
+ ::RegCloseKey(hkeyDummy);
+
+ return TRUE;
+ }
- HKEY hkeyDummy;
- if ( RegOpenKeyEx( (HKEY) hRootKey, szKey, 0, 0, &hkeyDummy) == ERROR_SUCCESS ) {
- RegCloseKey(hkeyDummy);
- return TRUE;
- }
- else
return FALSE;
}