if ( rc == ERROR_SUCCESS ) { char buffer[4096] = { 0 }; DWORD len = sizeof buffer; rc = ::RegQueryValueEx( key, valueNameArg(), NULL, NULL, (LPBYTE)buffer, &len ); if ( strcmp( setting, buffer ) != 0 ) { rc = ::RegSetValueEx( key, valueNameArg(), NULL, REG_SZ, (LPBYTE)(const char*)setting, strlen(setting) ); #ifdef DEBUG_law NS_WARN_IF_FALSE( rc == ERROR_SUCCESS, (const char*)fullName() ); #endif if ( rc == ERROR_SUCCESS ) { result = NS_OK; } } else {  result = NS_OK; } ::RegCloseKey( key ); } else { #ifdef DEBUG_law NS_WARN_IF_FALSE( rc == ERROR_SUCCESS, (const char*)fullName() ); #endif } return result;
return rv;
nsresult RegistryEntry::set() {#ifdef DEBUG_lawprintf( "Setting %s=%s\n", (const char*)fullName(), (const char*)setting );#endif    nsresult result = NS_ERROR_FAILURE;    HKEY   key;    LONG   rc = ::RegOpenKey( baseKey, keyName, &key );    // See if key doesn't exist yet...    if ( rc == ERROR_FILE_NOT_FOUND ) {        rc = ::RegCreateKey( baseKey, keyName, &key );    }    if ( rc == ERROR_SUCCESS ) {        char buffer[4096] = { 0 };        DWORD len = sizeof buffer;        rc = ::RegQueryValueEx( key, valueNameArg(), NULL, NULL, (LPBYTE)buffer, &len );        if ( strcmp( setting, buffer ) != 0 ) {            rc = ::RegSetValueEx( key, valueNameArg(), NULL, REG_SZ, (LPBYTE)(const char*)setting, strlen(setting) );#ifdef DEBUG_lawNS_WARN_IF_FALSE( rc == ERROR_SUCCESS, (const char*)fullName() );#endif            if ( rc == ERROR_SUCCESS ) {                result = NS_OK;            }        } else {            // Already has desired setting.            result = NS_OK;        }        ::RegCloseKey( key );    } else {#ifdef DEBUG_lawNS_WARN_IF_FALSE( rc == ERROR_SUCCESS, (const char*)fullName() );#endif    }    return result;}