NS_WITH_SERVICE(nsIPref, prefs, kPrefCID, &rv); NS_ASSERTION(NS_SUCCEEDED(rv), "failed to get prefs, so unable to save them"); if (NS_SUCCEEDED(rv)) { prefs->SavePrefFile(); }
nsCOMPtr<nsIPref> prefs = do_GetService(kPrefCID, &rv); NS_ASSERTION(NS_SUCCEEDED(rv), "failed to get prefs, so unable to save them"); if (NS_SUCCEEDED(rv)) prefs->SavePrefFile();
static nsresult DoOnShutdown(){  nsresult rv;  {    // Scoping this in a block to force the pref service to be    // released.    //  	// save the prefs, in case they weren't saved  	NS_WITH_SERVICE(nsIPref, prefs, kPrefCID, &rv);  	NS_ASSERTION(NS_SUCCEEDED(rv), "failed to get prefs, so unable to save them");  	if (NS_SUCCEEDED(rv)) {  		prefs->SavePrefFile();  	}  }  // at this point, all that is on the clipboard is a proxy object, but that object  // won't be valid once the app goes away. As a result, we need to force the data  // out of that proxy and properly onto the clipboard. This can't be done in the  // clipboard service's shutdown routine because it requires the parser/etc which  // has already been shutdown by the time the clipboard is shut down.  {    // scoping this in a block to force release    NS_WITH_SERVICE(nsIClipboard, clipService, "component://netscape/widget/clipboard", &rv);    if ( clipService )      clipService->ForceDataToClipboard(nsIClipboard::kGlobalClipboard);  }  return rv;}