WinCE自带数据库的问题
我最近想做一个WinCE自带的数据库的程序,用来做个人的账务管理,在网上看了好多资料了,照着做就是没有成功,请各位高手们不吝赐教。下面是我看到的一些代码。
PCEGUID CeGuid, CeGuid1;
CEOID CeOID, CeOID1;
CEDBASEINFOEX CeDBaseInfoEx;
BOOL bCre = CeMountDBVol(CeGuid, _T("\\Test.cdb"), OPEN_ALWAYS);(1)
DWORD error = ::GetLastError();(2)
HANDLE CDataBaseTestDlg::OpenDatabase(
HWND hwndNotify, // Handle to the window to which
// notification messages are posted.
PCEGUID pceguid, // Pointer to the mounted database
// volume in which the database that
// will be opened resides.
CEOID CeOid) // Object identifier of the database
// to be opened.
{
int index;
DWORD dwError; // Return value from GetLastError
HANDLE hDataBase; // Open handle to the address database
CENOTIFYREQUEST *pRequest; // CENOTIFYREQUEST structure
CEDBASEINFO CEDBInfo; // Structure containing the database data
TCHAR szError[100]; // String to use with error messages
// Allocate memory for pRequest.
pRequest =(CENOTIFYREQUEST *) LocalAlloc(LPTR, sizeof(CENOTIFYREQUEST));
pRequest->dwSize = sizeof(CENOTIFYREQUEST);
pRequest->hwnd = hwndNotify;
pRequest->hHeap = NULL; // Let system allocate memory properly.
pRequest->dwFlags = 0; // Notifications are handled as they were in Windows CE version 1.0.
hDataBase = CeOpenDatabaseEx(
pceguid, // Pointer to the mounted volume
&CeOid, // Location for the database identifier
TEXT("\\Point.cdb"), // Database name
0, // Sort order; 0 indicates to ignore
CEDB_AUTOINCREMENT, // Automatically increase seek pointer
pRequest); // Pointer to a CENOTIFYREQUEST
// structure
if(hDataBase == INVALID_HANDLE_VALUE)
{
dwError = GetLastError();
if(dwError == ERROR_NOT_ENOUGH_MEMORY)
{
wsprintf(szError, TEXT("Not enough memory"));
}
else
{
// Possibility of non-existent database; create it.
// Initialize structure CEDBInfo
memset(&CEDBInfo, 0, sizeof(CEDBInfo));
// Create the database with the following specified flags.
// Create the database as uncompressed.
// You can use CeSetDataBaseInfoEx to compress the database.
CEDBInfo.dwFlags =
CEDB_VALIDNAME // szDbaseName is valid
| CEDB_VALIDTYPE // dwDbaseType is valid
| CEDB_VALIDDBFLAGS // HIWORD of dwFlag is valid
| CEDB_VALIDSORTSPEC // rgSortSpecs is valid
| CEDB_NOCOMPRESS; // The database is not compressed.
// Assign the database name as Test.cdb.
wcscpy(CEDBInfo.szDbaseName, TEXT("MyDB"));
// Assign the database type.
CEDBInfo.dwDbaseType = 0;
// Set the number of active sort orders to 4.
// This is the maximum number allowed.
CEDBInfo.wNumSortOrder = 4;
// Initialize the array of sort-order descriptions.
for(index = 0; index < CEDBInfo.wNumSortOrder; ++index)
{
// Sort in descending order.
CEDBInfo.rgSortSpecs[index].dwFlags = CEDB_SORT_DESCENDING;
// Assign the identifier of the properties by which to sort.
// CEDBInfo.rgSortSpecs[index].propid = ...;
}
// Create database "Test.cdb".
CeOid = CeCreateDatabaseEx(pceguid, &CEDBInfo);
if(CeOid == NULL)
{
wsprintf(szError,
TEXT("ERROR:CeCreateDatabaseEx failed(%ld)"),
GetLastError());
}
else // Succeeded in creating the database; open it.
{
hDataBase = CeOpenDatabaseEx(pceguid, &CeOid,
TEXT("MyDB"), 0, 0, pRequest);
}
}
}
(1)如果从台式机上创建一个文件,然后将后缀名改成cdb,那么本条语句返回1,否则总是返回0
(2)如果(1)返回1,那么这条就返回183,如果(1)返回0,这条就返回87.
请各位高手帮忙看看啊,多谢了
PCEGUID CeGuid, CeGuid1;
CEOID CeOID, CeOID1;
CEDBASEINFOEX CeDBaseInfoEx;
BOOL bCre = CeMountDBVol(CeGuid, _T("\\Test.cdb"), OPEN_ALWAYS);(1)
DWORD error = ::GetLastError();(2)
HANDLE CDataBaseTestDlg::OpenDatabase(
HWND hwndNotify, // Handle to the window to which
// notification messages are posted.
PCEGUID pceguid, // Pointer to the mounted database
// volume in which the database that
// will be opened resides.
CEOID CeOid) // Object identifier of the database
// to be opened.
{
int index;
DWORD dwError; // Return value from GetLastError
HANDLE hDataBase; // Open handle to the address database
CENOTIFYREQUEST *pRequest; // CENOTIFYREQUEST structure
CEDBASEINFO CEDBInfo; // Structure containing the database data
TCHAR szError[100]; // String to use with error messages
// Allocate memory for pRequest.
pRequest =(CENOTIFYREQUEST *) LocalAlloc(LPTR, sizeof(CENOTIFYREQUEST));
pRequest->dwSize = sizeof(CENOTIFYREQUEST);
pRequest->hwnd = hwndNotify;
pRequest->hHeap = NULL; // Let system allocate memory properly.
pRequest->dwFlags = 0; // Notifications are handled as they were in Windows CE version 1.0.
hDataBase = CeOpenDatabaseEx(
pceguid, // Pointer to the mounted volume
&CeOid, // Location for the database identifier
TEXT("\\Point.cdb"), // Database name
0, // Sort order; 0 indicates to ignore
CEDB_AUTOINCREMENT, // Automatically increase seek pointer
pRequest); // Pointer to a CENOTIFYREQUEST
// structure
if(hDataBase == INVALID_HANDLE_VALUE)
{
dwError = GetLastError();
if(dwError == ERROR_NOT_ENOUGH_MEMORY)
{
wsprintf(szError, TEXT("Not enough memory"));
}
else
{
// Possibility of non-existent database; create it.
// Initialize structure CEDBInfo
memset(&CEDBInfo, 0, sizeof(CEDBInfo));
// Create the database with the following specified flags.
// Create the database as uncompressed.
// You can use CeSetDataBaseInfoEx to compress the database.
CEDBInfo.dwFlags =
CEDB_VALIDNAME // szDbaseName is valid
| CEDB_VALIDTYPE // dwDbaseType is valid
| CEDB_VALIDDBFLAGS // HIWORD of dwFlag is valid
| CEDB_VALIDSORTSPEC // rgSortSpecs is valid
| CEDB_NOCOMPRESS; // The database is not compressed.
// Assign the database name as Test.cdb.
wcscpy(CEDBInfo.szDbaseName, TEXT("MyDB"));
// Assign the database type.
CEDBInfo.dwDbaseType = 0;
// Set the number of active sort orders to 4.
// This is the maximum number allowed.
CEDBInfo.wNumSortOrder = 4;
// Initialize the array of sort-order descriptions.
for(index = 0; index < CEDBInfo.wNumSortOrder; ++index)
{
// Sort in descending order.
CEDBInfo.rgSortSpecs[index].dwFlags = CEDB_SORT_DESCENDING;
// Assign the identifier of the properties by which to sort.
// CEDBInfo.rgSortSpecs[index].propid = ...;
}
// Create database "Test.cdb".
CeOid = CeCreateDatabaseEx(pceguid, &CEDBInfo);
if(CeOid == NULL)
{
wsprintf(szError,
TEXT("ERROR:CeCreateDatabaseEx failed(%ld)"),
GetLastError());
}
else // Succeeded in creating the database; open it.
{
hDataBase = CeOpenDatabaseEx(pceguid, &CeOid,
TEXT("MyDB"), 0, 0, pRequest);
}
}
}
(1)如果从台式机上创建一个文件,然后将后缀名改成cdb,那么本条语句返回1,否则总是返回0
(2)如果(1)返回1,那么这条就返回183,如果(1)返回0,这条就返回87.
请各位高手帮忙看看啊,多谢了
...全文
相关推荐
WinCE下的注册表工具
## 一、WinCE注册表概述WinCE的注册表结构类似于桌面版Windows的注册表,它是由一系列键(Keys)、子键(Subkeys)和值(Values)组成的层次型数据库。
WinCE DB 数据库开发
三、WinCE DB开发基础1. 数据库创建:首先,你需要在EVC项目中引入SQL Server CE库,然后通过API创建数据库文件。
wince连接远程sqlserver数据库
在Windows CE(Wince)平台上连接到远程SQL Server数据库是一项技术性的工作,涉及到多个关键组件和步骤。
Oracle Database Lite for WinCE
### Oracle Database Lite for WinCE:构建移动应用教程#### 概述Oracle Database Lite for Windows CE(以下简称“Oracle Database
WinCE下使用sqlite数据库
open database: %s\n", sqlite3_errmsg(db)); return 1; } /* 执行 SQL 语句 */ rc = sqlite3_exec(db, "CREATE


