Benjamin

静以修身,俭以养德,非澹薄无以明志,非宁静无以致远。
随笔 - 388, 文章 - 0, 评论 - 196, 引用 - 0
数据加载中……

WM5.0监听EDB数据库变化的WM_DBNOTIFICATION消息的注册和使用


在Main中GetMessage,或用MFC直接注册这个消息(手动加):
h文件中声明消息处理涵数:
afx_msg LRESULT OnProcess(WPARAM wParam, LPARAM lParam);
在cpp文件的消息映射中加上:
ON_MESSAGE(WM_DBNOTIFICATION,OnProcess)
关加上实现代码:前提是EDB数据库必须打开,可监听联系人,来电数据库的变化.
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;
}
相对于CEDB,则是CEDB_EXNOTIFICATION.这个消息不适用短信数据库(cemail.vol),

posted on 2008-08-20 15:34 Benjamin 阅读(605) 评论(0)  编辑 收藏 引用 所属分类: PDA/PPC开发


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理