MailSaveMngr.cpp
上传用户:weimei12
上传日期:2022-08-11
资源大小:185k
文件大小:1k
- #include "StdAfx.h"
- #include "MailSaveMngr.h"
- #include <Shlwapi.h>
- #include <windows.h>
- CMailSaveMngr::CMailSaveMngr(void)
- {
- }
- CMailSaveMngr::~CMailSaveMngr(void)
- {
- }
- ///<summary>
- /// Save the mails and return the mail position
- ///</summary>
- BOOL CMailSaveMngr::SaveMail(LPCTSTR szMail, const int nMailLen, MAILPOS& sMailPos)
- {
- sMailPos.nBlockIndex = m_MailTmpFile.ApplyMailBlocks(1);
- m_MailTmpFile.WriteMailBlock(sMailPos.nBlockIndex, (void*)szMail, nMailLen);
- return TRUE;
- }
- ///<summary>
- /// load the mail content
- ///</summary>
- BOOL CMailSaveMngr::LoadMail(MAILPOS sMailPos, LPCTSTR szMail, int nMailLen)
- {
- m_MailTmpFile.ReadMailBlock(sMailPos.nBlockIndex, nMailLen, (void*)szMail);
- return TRUE;
- }
- ///<summary>
- /// delete the certain mail from the database
- ///</summary>
- void CMailSaveMngr::DelMail(MAILPOS sMailPos)
- {
- m_MailTmpFile.ReleaseMailBlocks(sMailPos.nBlockIndex, 1);
- }
- ///<summary>
- /// initial the database to save the mails
- ///</summary>
- BOOL CMailSaveMngr::InitMailTmpFile()
- {
- TCHAR szDatabase[_MAX_PATH] = {0};
- GetModuleFileName(NULL, szDatabase, _MAX_PATH);
- PathRemoveFileSpec(szDatabase);
- _tcscat_s(szDatabase, _MAX_PATH, MAIL_FILE_NAME);
- if (PathFileExists(szDatabase))
- {
- m_MailTmpFile.Open(szDatabase, TRUE);
- return TRUE;
- }
- else
- {
- m_MailTmpFile.CreateEmptyFile(szDatabase);
- return FALSE;
- }
- }