none
Win CE RRS feed

  • 问题

  • 小妹最近在做WIN CE 本地数据库的例子,参照着原书编程.但终有error C2601: 'OpenDatabase' : local function definitions are illegal的错误..原程序是

    void CMy1Dlg::OnButton6()
    {
     // TODO: Add your control notification handler code here
     HANDLE OpenDatabase(HWND hwndNotify, PCEGUID pceguid, CEOID CeOid)
    {
      int intdex;
      DWORD dwError;
      HANDLE hDataBase;
      CENOTIFYREUEST *pRequest;
      CEDBASEINFO CEDBInfo;
      TCHAR szError[100];

      pRequest=(CENOTIFYREQUEST *)LocalAlloc(LPTR,sizeof(CENOTIFYREQUEST));
      pRequest->dwSize=sizeof(CENOFIFYREQUEST);
      pRequest->hwnd=hwndNotify;
      pRequest->hHeap=NULL;
      pRequest->dwFlags=0;

      hDataBase=CeOpenDatabaseEx(pceguid,&CeOid.TEXT("MyDBase"),0,CEDB_AUTOINCREAMENT,pRequest);
      if(hDataBase==INVALID_HANDLE_VALUE)
      {
       dwError=GetLastError();
       if(dwError==ERROR_NOT_ENOUGH_MEMORY)
       {
        wsprintf(szError,TEXT("Not enough memory"));
       }else{
        memset(&CEDBInfo,0,sizeof(CEDBInfo));
                 CEDBInfo.dwFlags=CEDB_VALIDNAME|CEDB_VALIDTYPE|CEDB_VALIDDBFLAGS|CEDB_VALIDSORTSPEC|CEDB_NOCOMPRESS;
                 wcscpy(CEDBInfo.szDbaseName,TEXT("MyDBase"));
                   CEDBInfo.dwDbaseType=0;
                 CEDBInfo.wNumSortOrder=4;
                 for(index=0;index<CEDBInfo.wNumSortOrder;++index)
        {
                  CEDBInfo.rgSortSpecs[index].dwFlags=CEDB_SORT_DESCENDING;
        }
        CeOid=CeCreateDatabaseEx(pceguid,&CEDBInfo);
        if(CeOid==NULL)
        {
         wsprintf(szError,TEXT("ERROR:CeCreateDatabaseEx failed(%1d)"),GetLastError());
        }else{
         hDataBase=CeOpenDatabaseEx(pceguid,&CeOid,TEXT("MyDBase"),0,0,pRequest);
        }
       }
      }
      return hDataBase;
     }

    }

    请各位高手帮忙分析下,到底哪里的问题,该如何改错误呢?

    2010年8月8日 8:20

答案