CeGetDatabaseProps

Now that CEDB is deprecated in Windows Mobile 5.0, you may be running across one gotcha in the EDB API, namely, CeGetDatabaseProps().  From reading the docs, you might think that you can call CeGetDatbaseProps like this:

       CeGetDatabaseProps(m_hDb, &wNumProps, NULL, NULL))

CEPROPID *rgPropID = new CEPROPID[wNumProps+1];
CEPROPSPEC* prgProps = new CEPROPSPEC[wNumProps+1];

       CeGetDatabaseProps(m_hDb, &wNumProps, rgPropID, prgProps);

       for (int i=0; i<wNumProps; i++)
{
// Do something
}

 

But, actually, you need to set up the CEPROPSPECs first:

       CeGetDatabaseProps(m_hDb, &wNumProps, NULL, NULL))

CEPROPID *rgPropID = new CEPROPID[wNumProps+1];
CEPROPSPEC* prgProps = new CEPROPSPEC[wNumProps+1];

       for (int i=0; i< wNumProps; i++)
{

           prgProps[i].wVersion = CEPROPSPEC_VERSION;

           prgProps[i].pwszPropName = new WCHAR[ CEDB_MAXDBASENAMELEN ];

           prgProps[i].cchPropName= CEDB_MAXDBASENAMELEN; // We need to specify the length of buffer we are passing in for pwszPropName

        }

CeGetDatabaseProps(m_hDb, &wNumProps, rgPropID, prgProps);

for (int i=0; i<wNumProps; i++)
{
// Do something
}