stry::WriteDWORD( const char *lpszValueName, DWORD dwData, DWORD *pdwLastError )
{
if( m_hKey == NULL )
return( FALSE );
m_nSize = sizeof( DWORD );
BOOL bRet = Write( lpszValueName, &dwData, REG_DWORD, sizeof( DWORD ) );
if( pdwLastError != NULL )
*pdwLastError = m_dwLastError;
return( bRet );
}
BOOL CRegistry::WriteString( const char *lpszValueName, LPVOID lpData, DWORD *pdwLastError )
{
if( m_hKey == NULL )
return( FALSE );
m_nSize = 2000;
BOOL bRet = Write( lpszValueName, lpData, REG_SZ, (DWORD) strlen( (const char *) lpData ) + 1 );
if( pdwLastError != NULL )
*pdwLastError = m_dwLastError;
return( bRet );
}
BOOL CRegistry::Write( const char *lpszValueName, LPVOID lpData, DWORD dwType, int nSize )
{
if( m_hKey == NULL )
return( FALSE );
DWORD dwSize = (DWORD) m_nSize;
BOOL bRet = ( ::RegSetValueEx( m_hKey, lpszValueName, 0, dwType, (unsigned char *) lpData, nSize ) == ERROR_SUCCESS );
m_dwLastError = GetLastError();
return( bRet );
}
BOOL CRegistry::CreateKey( HKEY hKey, const char *lpszSubKey, const char *lpszClass )
{
HKEY hOpenedKey;
DWORD dwDisposition;
DWORD dwLastError;
BOOL bRet = ( ::RegCreateKeyEx( hKey, lpszSubKey, 0, (char *) lpszClass, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hOpenedKey, &dwDisposition ) == ERROR_SUCCESS );
if( bRet ) ::RegCloseKey( hOpenedKey );
dwLastError = GetLastError();
return( bRet );
}
BOOL CRegistry::DeleteKey( HKEY hKey, const char *lpszSubKey )
{
BOOL bRet;
DWORD dwLastError;
bRet = ( ::RegDeleteKey( hKey, lpszSubKey ) == ERROR_SUCCESS );
dwLastError = GetLastError();
return( bRet );
}