在Main中GetMessage,或用MFC直接注冊(cè)這個(gè)消息(手動(dòng)加):
h文件中聲明消息處理涵數(shù):
afx_msg LRESULT OnProcess(WPARAM wParam, LPARAM lParam);
在cpp文件的消息映射中加上:
ON_MESSAGE(WM_DBNOTIFICATION,OnProcess)
關(guān)加上實(shí)現(xiàn)代碼:前提是EDB數(shù)據(jù)庫必須打開,可監(jiān)聽聯(lián)系人,來電數(shù)據(jù)庫的變化.
LRESULT CMainFrame::OnProcess(WPARAM wParam, LPARAM lParam)
{
CENOTIFICATION *pNotification = NULL;
pNotification = (CENOTIFICATION*)lParam;
if( pNotification->uType != DB_CEOID_CREATED)
return S_FALSE;
if(INVALID_HANDLE_VALUE == CeGetDatabaseSession(g_hDB))
return S_FALSE;
pNotification = (CENOTIFICATION*)lParam;
CEOID oid = pNotification->oid;
WORD wNumRecProps = 0;
LPBYTE lpRecProps = NULL;
PCEPROPVAL pCePropVal;
DWORD dwBufLen = 128;
CEOID ceoid = CeSeekDatabaseEx(g_hDB,CEDB_SEEK_CEOID,oid,1,NULL);
if(!ceoid)
{
DWORD dwErr = GetLastError();
return dwErr;
}
ceoid = CeReadRecordPropsEx(g_hDB, CEDB_ALLOWREALLOC, &wNumRecProps, NULL, &lpRecProps, &dwBufLen, NULL);
if(!ceoid)
{
DWORD dwErr = GetLastError();
return dwErr;
}
pCePropVal = (PCEPROPVAL)lpRecProps;
CeFreeNotification(&edbCalllog,pNotification);
//////////////////////////////////////////////////////////////////////
return S_OK;
}
相對(duì)于CEDB,則是CEDB_EXNOTIFICATION.這個(gè)消息不適用短信數(shù)據(jù)庫(cemail.vol),