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

@@ -376,31 +376,36 @@ bool wxRegKey::GetKeyInfo(size_t *pnSubKeys,
// 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;
@@ -1083,16 +1088,25 @@ bool wxRegKey::IsNumericValue(const wxChar *szValue) const
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;
}