rv = accMgr->SaveAccountInfo(); NS_ASSERTION(NS_SUCCEEDED(rv), "Can't save account info to pref file");
PRBool OESettings::DoImport( nsIMsgAccount **ppAccount){	HKEY	hKey = FindAccountsKey();	if (hKey == nsnull) {		IMPORT_LOG0( "*** Error finding Outlook Express registry account keys\n");		return( PR_FALSE);	}	nsresult	rv;		NS_WITH_SERVICE( nsIMsgAccountManager, accMgr, kMsgAccountMgrCID, &rv);    if (NS_FAILED(rv)) {		IMPORT_LOG0( "*** Failed to create a account manager!\n");		return( PR_FALSE);	}	HKEY		subKey;	nsCString	defMailName;	// First let's get the default mail account key name	if (::RegOpenKeyEx( HKEY_CURRENT_USER, "Software\\Microsoft\\Outlook Express", 0, KEY_QUERY_VALUE, &subKey) == ERROR_SUCCESS) {		BYTE *	pBytes = nsOERegUtil::GetValueBytes( subKey, "Default Mail Account");		::RegCloseKey( subKey);		if (pBytes) {			defMailName = (const char *)pBytes;			nsOERegUtil::FreeValueBytes( pBytes);		}	}	// Iterate the accounts looking for POP3 & IMAP accounts...	// Ignore LDAP & NNTP for now!	DWORD		index = 0;	DWORD		numChars;	TCHAR		keyName[256];	FILETIME	modTime;	LONG		result = ERROR_SUCCESS;	BYTE *		pBytes;	int			popCount = 0;	int			accounts = 0;	nsCString	keyComp;	while (result == ERROR_SUCCESS) {		numChars = 256;		result = ::RegEnumKeyEx( hKey, index, keyName, &numChars, NULL, NULL, NULL, &modTime);		index++;		if (result == ERROR_SUCCESS) {			if (::RegOpenKeyEx( hKey, keyName, 0, KEY_QUERY_VALUE, &subKey) == ERROR_SUCCESS) {				// Get the values for this account.				IMPORT_LOG1( "Opened Outlook Express account: %s\n", (char *)keyName);				nsIMsgAccount	*anAccount = nsnull;				pBytes = nsOERegUtil::GetValueBytes( subKey, "IMAP Server");				if (pBytes) {					if (DoIMAPServer( accMgr, subKey, (char *)pBytes, &anAccount))						accounts++;					nsOERegUtil::FreeValueBytes( pBytes);				}				pBytes = nsOERegUtil::GetValueBytes( subKey, "POP3 Server");				if (pBytes) {					if (popCount == 0) {						if (DoPOP3Server( accMgr, subKey, (char *)pBytes, &anAccount)) {							popCount++;							accounts++;							if (ppAccount && anAccount) {								*ppAccount = anAccount;								NS_ADDREF( anAccount);							}						}					}					else {						if (DoPOP3Server( accMgr, subKey, (char *)pBytes, &anAccount)) {							popCount++;							accounts++;							// If we created a mail account, get rid of it since							// we have 2 POP accounts!							if (ppAccount && *ppAccount) {								NS_RELEASE( *ppAccount);								*ppAccount = nsnull;							}						}					}					nsOERegUtil::FreeValueBytes( pBytes);				}								if (anAccount) {					// Is this the default account?					keyComp = keyName;					if (keyComp.Equals( defMailName)) {						accMgr->SetDefaultAccount( anAccount);					}					NS_RELEASE( anAccount);				}				::RegCloseKey( subKey);			}		}	}	return( accounts != 0);}