} else {  char buffer[4096] = { 0 }; DWORD len = sizeof buffer; rc = ::RegQueryValueEx( key, valueNameArg(), NULL, NULL, (LPBYTE)buffer, &len ); if ( rc != ERROR_SUCCESS || strcmp( setting.get(), buffer ) != 0 ) { rc = ::RegSetValueEx( key, valueNameArg(), NULL, REG_SZ, (LPBYTE)setting.get(), setting.Length() ); #ifdef DEBUG_law NS_WARN_IF_FALSE( rc == ERROR_SUCCESS, fullName().get() ); #endif if ( rc == ERROR_SUCCESS ) { result = NS_OK; } } else {  result = NS_OK;
nsCAutoString iconKey( "Software\\Classes\\" ); iconKey += protocol; iconKey += "\\DefaultIcon";  RegistryEntry iconEntry( HKEY_LOCAL_MACHINE, iconKey.get(), NULL, nsCAutoString( thisApplication() + NS_LITERAL_CSTRING(",0") ).get() );  if ( iconEntry.currentSetting().IsEmpty() ) { iconEntry.set();
nsresult RegistryEntry::set() {#ifdef DEBUG_lawif ( isNull && setting.IsEmpty() ) printf( "Deleting %s\n", fullName().get() );else printf( "Setting %s=%s\n", fullName().get(), setting.get() );#endif    nsresult result = NS_ERROR_FAILURE;    HKEY   key;    LONG   rc = ::RegOpenKey( baseKey, keyName.get(), &key );    // See if key doesn't exist yet...    if ( rc == ERROR_FILE_NOT_FOUND ) {        rc = ::RegCreateKey( baseKey, keyName.get(), &key );    }    if ( rc == ERROR_SUCCESS ) {        if ( isNull && setting.IsEmpty() ) {            // This means we need to actually remove the value, not merely set it to an            // empty string.            rc = ::RegDeleteValue( key, valueNameArg() );            if ( rc == ERROR_SUCCESS ) {                result = NS_OK;            }        } else {            // Get current value to see if it is set properly already.            char buffer[4096] = { 0 };            DWORD len = sizeof buffer;            rc = ::RegQueryValueEx( key, valueNameArg(), NULL, NULL, (LPBYTE)buffer, &len );            if ( rc != ERROR_SUCCESS || strcmp( setting.get(), buffer ) != 0 ) {                rc = ::RegSetValueEx( key, valueNameArg(), NULL, REG_SZ, (LPBYTE)setting.get(), setting.Length() );#ifdef DEBUG_lawNS_WARN_IF_FALSE( rc == ERROR_SUCCESS, fullName().get() );#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, fullName().get() );#endif    }    return result;}