CEDB 读取cemail.vol实例(WindowsMobile5 读取CEDB数据库)

CEDB 读取cemail.vol实例

众所周知cemail是与短信有关的数据库。由于cemail属于CEDB(pim属于EDB),如果采用EDB的API去访问cemail经常会产生以下两种错误:
1. 另一个程序正在使用此文件,进程无法访问。.
2. 参数死活无效。

以下程序简单的阐述了访问cemail的步骤,不完善的地方请补充:
#define EDB
#include "stdafx.h"
#include <windows.h>
#include <windbase.h>
#include <commctrl.h>


BOOL Test_EDB06( TCHAR *pwszVolName, TCHAR *pwszDBName )
{
        CEGUID ceguidCemail;
        CEOID  ceoidFind;
        CEOID  coidRecord;
        CEOID  oidDB;
        BOOL   bResult;
        DWORD  dwError;

        bResult      = FALSE;
        coidRecord = 0;
        ceoidFind    = 0;
        oidDB         = 0;
        dwError      = 0;

        //  Fill in the DBInfo structure
        CREATE_SYSTEMGUID( &ceguidCemail );

        if(!CeMountDBVol( &ceguidCemail, pwszVolName , OPEN_EXISTING))
        {

                bResult = FALSE;
                return FALSE;
        }

        HANDLE hSession = CeOpenDatabaseEx2(&ceguidCemail, &oidDB, pwszDBName, 0, CEDB_AUTOINCREMENT, NULL  );
        if ( hSession == INVALID_HANDLE_VALUE )
        {
                dwError =  GetLastError();
                return FALSE;
        }

        ceoidFind = CeSeekDatabaseEx(hSession, CEDB_SEEK_BEGINNING, 0, 0, NULL);
        if (!ceoidFind )
        {
                dwError =  GetLastError();
                return FALSE;
        }

        WORD wNumProps = 0;
        CEPROPVAL *pRecord = NULL;
        DWORD dwBufSize = 0;
        while (coidRecord = CeReadRecordPropsEx(hSession, CEDB_ALLOWREALLOC, &wNumProps, NULL, (LPBYTE *)&pRecord, &dwBufSize, NULL))
        {
                for (int i = 0; i < wNumProps; i++)
                {
                 // you can do something
               }
        }

        CeUnmountDBVol(&ceguidCemail);
        return bResult;

}

int _tmain(int argc, _TCHAR* argv[])
{
        Test_EDB06( L"cemail.vol", _T("fldr31000024") );
        return 0;
}

 

地址:http://www.devdiv.net/bbs/archiver/tid-8579.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值