fixed incorrect RegOpenKeyEx() usage

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@21920 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2003-07-12 14:18:04 +00:00
parent d80096a2dd
commit 8a8c41dd93

View File

@@ -380,27 +380,32 @@ bool wxRegKey::Open()
return TRUE; return TRUE;
HKEY tmpKey; HKEY tmpKey;
m_dwLastError = RegOpenKeyEx((HKEY) m_hRootKey, m_strKey, m_dwLastError = ::RegOpenKeyEx
0, 0, &tmpKey); (
if ( m_dwLastError != ERROR_SUCCESS ) { (HKEY) m_hRootKey,
m_strKey,
RESERVED,
KEY_ALL_ACCESS,
&tmpKey
);
if ( m_dwLastError != ERROR_SUCCESS )
{
wxLogSysError(m_dwLastError, _("Can't open registry key '%s'"), wxLogSysError(m_dwLastError, _("Can't open registry key '%s'"),
GetName().c_str()); GetName().c_str());
return FALSE; return FALSE;
} }
else
{
m_hKey = (WXHKEY) tmpKey; m_hKey = (WXHKEY) tmpKey;
return TRUE; return TRUE;
}
} }
// creates key, failing if it exists and !bOkIfExists // creates key, failing if it exists and !bOkIfExists
bool wxRegKey::Create(bool bOkIfExists) bool wxRegKey::Create(bool bOkIfExists)
{ {
// check for existence only if asked (i.e. order is important!) // check for existence only if asked (i.e. order is important!)
if ( !bOkIfExists && Exists() ) { if ( !bOkIfExists && Exists() )
return FALSE; return FALSE;
}
if ( IsOpened() ) if ( IsOpened() )
return TRUE; return TRUE;
@@ -1088,11 +1093,20 @@ bool KeyExists(WXHKEY hRootKey, const wxChar *szKey)
return TRUE; return TRUE;
HKEY hkeyDummy; HKEY hkeyDummy;
if ( RegOpenKeyEx( (HKEY) hRootKey, szKey, 0, 0, &hkeyDummy) == ERROR_SUCCESS ) { if ( ::RegOpenKeyEx
RegCloseKey(hkeyDummy); (
(HKEY)hRootKey,
szKey,
RESERVED,
KEY_ALL_ACCESS,
&hkeyDummy
) == ERROR_SUCCESS )
{
::RegCloseKey(hkeyDummy);
return TRUE; return TRUE;
} }
else
return FALSE; return FALSE;
} }