DBFEngine.h
上传用户:hjb520
上传日期:2022-08-08
资源大小:1251k
文件大小:3k
源码类别:

Windows CE

开发平台:

Visual C++

  1. #ifndef _DBF_H
  2. #define _DBF_H
  3. #define ASCEND  0
  4. #define DESCEND 1
  5. struct strField
  6. {
  7. TCHAR m_pfieldName[11];
  8. TCHAR m_fieldType;
  9. UINT m_fieldLen;
  10. UINT m_decCount;//XIAO SHU's counts
  11. };
  12. class CDbFile: public CObject
  13. {
  14. public:
  15. public:
  16. CDbFile();
  17. ~CDbFile();
  18. bool OpenDbf(LPTSTR pfileName);
  19. bool CloseDbf();
  20. BOOL InitHeadStructure();
  21. void GetFieldInfo();
  22. CString CharToWideChar(PBYTE,DWORD);
  23. int WideCharToChar(CString,char*);
  24. DWORD ReadFieldStr(UINT nRecNumber,UINT nFieldNum,PBYTE fieldBuffers);
  25.     DWORD SetFieldStr(UINT nRecNumber,UINT nFieldNum,PBYTE fieldBuffers);
  26. DWORD AppendRecord();
  27. DWORD WriteAllDataToFile();
  28. DWORD SetFieldStr(UINT nRecNumber,UINT nFieldNum,PBYTE fieldBuffers,DWORD dwLen);
  29. DWORD AppendBlankRecordInMem();
  30. DWORD DeleteRecordInMem(int num);
  31. DWORD SetRecordCountInMem(int num);
  32. WORD GetFieldCount();//return field count.
  33. DWORD GetRecordCount();
  34. WORD  GetHeadLen();
  35. WORD  GetRecordLen();
  36. PBYTE GetAllDataPointer();
  37. strField* GetFieldInfoArray();
  38. BOOL DeleteAllDataPointer();
  39. BOOL DeleteFieldInfoArrayPointer();
  40. BYTE GetB(HANDLE hFile,DWORD offset);//return a byte from file's offset
  41. WORD GetW(HANDLE hFile,DWORD offset,bool DIRECT);//return a word from file's offset
  42. DWORD GetDW(HANDLE hFile,DWORD offset,bool DIRECT);//return a double word from file's offset
  43. bool OpenFpt(LPTSTR pfileName);
  44. bool CloseFpt();
  45. //DWORD GetMemoFieldFromDbfFile(UINT nRecNumber,UINT nFieldNum,PBYTE fieldBuffers);
  46. DWORD GetFptDataUnitLen();
  47. DWORD GetMemoFieldCommentLen(DWORD dwOffsetBlockNum);
  48. DWORD GetMemoFieldOffsetNumFromDbfFile(UINT nRecNumber,UINT nFieldNum,PBYTE fieldBuffers);
  49. DWORD InitGetMemField(UINT nRecNumber,UINT nFieldNum,PBYTE fieldBuffers);//return len for GetMemFieldStr()
  50. DWORD GetMemoFieldFromDbf(UINT nRecNumber,PBYTE fieldBuffers);
  51. DWORD SetFieldOffset(UINT nFieldNum);
  52. DWORD SetFieldLen(UINT nFieldNum);
  53. DWORD GetFieldStr(UINT nRecNumber,PBYTE fieldBuffers);
  54. DWORD InitGetMemField(UINT nRecNumber,PBYTE fieldBuffers);
  55. DWORD GetMemFieldStr(PBYTE memoFieldBuffers,DWORD len);
  56. DWORD GetFptFileSize();
  57. DWORD GetMemFieldStr(UINT nRecNumber,PBYTE fieldBuffers);
  58. DWORD GetMemFieldSize(PBYTE allFptDataBuf,UINT nRecNumber);
  59. DWORD GetMemFieldStrFromMemory(PBYTE allFptDataBuf,UINT nRecNumber,PBYTE fieldBuffers,DWORD n);
  60. BOOL ReadFptToMemory(PBYTE);
  61. HANDLE GetFptHandle();
  62. //////////////////////////////////////////
  63. //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  64. //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  65. HANDLE  OpenFile(LPTSTR pfileName);
  66. BOOL CloseFile(HANDLE  hFile);
  67. BOOL GetRecordCount(LPBYTE pAllData,DWORD& recordCount);
  68. BOOL GetRecordLen(LPBYTE pAllData,DWORD& recordLen);
  69. BOOL GetHeadLen(LPBYTE pAllData,DWORD& headLen);
  70. BOOL GetFieldCount(DWORD headLen,DWORD& fieldCount);
  71. BOOL GetFileSize(HANDLE  hFile,DWORD& len);
  72. BOOL ReadAllData(HANDLE  hFile,LPBYTE pAllData,DWORD len,DWORD dwFileLen);
  73. void GetFieldInfo(LPBYTE pAllData,DWORD fieldCount,strField* pFieldInfoArray);
  74. DWORD ReadFieldStr(LPBYTE pAllData,strField* pFieldInfoArray,
  75. DWORD headLen,DWORD recordLen,
  76. UINT nRecNumber,UINT nFieldNum,PBYTE fieldBuffers);
  77. //CString GetInstallDir();
  78. CString GetExeDir();
  79. };
  80. #endif
  81. /////////////////////////////////////////////////////////////////////////////