/*++ Copyright (c) 1989 Microsoft Corporation Module Name: JetWalk.cxx Abstract: Dumps a Jet database Author: Rajivendra Nath (RajNath) 18-Aug-1989 Revision History: David Orbits (davidor) 6-March-1997 Revised for NTFRS database and major rework. --*/ #include #include #include #include #define BUFFER_SIZE 1024 JET_ERR DbStats( JET_SESID jsesid, char * szDbName ); void TblStats( JET_SESID jsesid, JET_DBID jdbid, int iTable, char *szTblName, unsigned long *pcPages ); void DumpAttributes( JET_SESID jsesid, JET_COLUMNLIST colinfo ); void DumpIndex( JET_SESID jsesid, JET_INDEXLIST colinfo ); void DBDumpTable( JET_SESID jsesid,JET_TABLEID jtid, char* rgb); void DBDumpRecord( JET_SESID jsesid,JET_TABLEID jtid); typedef char* SZ; typedef ULONG CCH; typedef struct { char AttribName[64]; JET_COLUMNID colid; JET_COLTYP coltyp; JET_GRBIT grbit; BOOL Display; }ATTRIBLIST; typedef struct { char AttribName[64]; char key[256]; JET_COLUMNID colid; JET_COLTYP coltyp; JET_GRBIT grbit; BOOL Display; }INDEXLIST; DWORD List[1024]; ATTRIBLIST AList[1024]; DWORD AListUsed; INDEXLIST IList[1024]; DWORD IListUsed; BOOL NeedShutdown = FALSE; char *JetColumnTypeNames[] = { "coltypNil ", "coltypBit ", "coltypUnsignedByte", "coltypShort ", "coltypLong ", "coltypCurrency ", "coltypIEEESingle ", "coltypIEEEDouble ", "coltypDateTime ", "coltypBinary ", "coltypText ", "coltypLongBinary ", "coltypLongText ", "coltypMax "}; #define TIMECALL(CallX) \ { \ DWORD start,end; \ start = GetTickCount(); \ CallX; \ end = GetTickCount(); \ printf("[%5d MilliSec] <<%s>> \n",end-start,#CallX);\ } void ReadSzFromRegKey(SZ szKey, SZ szValue, SZ szBuf, CCH cchBuf) { HKEY hkey = NULL; // User specified that we use the regular registry variables. if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, szKey, 0, KEY_READ, &hkey) == ERROR_SUCCESS) { DWORD dwType; ULONG cb; cb = cchBuf; if ((RegQueryValueEx(hkey, szValue, 0, &dwType, (LPBYTE) szBuf, &cb) == ERROR_SUCCESS) && cb > 0 && (dwType == REG_SZ || dwType == REG_EXPAND_SZ)) { return; } } printf("Couldn't read value %s from registry key %s.", szValue, szKey); exit(1); } BOOL fDumpRecords=FALSE; BOOL fDumpAll=FALSE; BOOL fDumpColId=FALSE; ULONG _cdecl main( IN INT argc, IN PCHAR argv[] ) { JET_ERR jerr; JET_INSTANCE jinstance; JET_SESID jsesid; char szBuffer[BUFFER_SIZE]; char * szUserName = "admin"; char * szPassword = "password"; int nTotalLen; jerr = JetSetSystemParameter(&jinstance, 0, JET_paramRecovery, 0, "off"); if (jerr != JET_errSuccess) { printf( "jetwalk: JetSetSystemParameter returned %d\n", jerr ); return jerr; } // // Open JET session // TIMECALL(jerr = JetInit(&jinstance)); if (jerr != JET_errSuccess) { printf("JetInit error: %d\n", jerr); return jerr; } // // If we fail after here, our caller should go through full shutdown // so JetTerm will be called to release any file locks // NeedShutdown = TRUE; if ((jerr = JetBeginSession(jinstance, &jsesid, NULL, NULL)) != JET_errSuccess) { printf("JetBeginSession error: %d\n", jerr); return jerr; } if (argc<2) { printf("Usage:%0 [/R] "); } char* FileName="e:\\ntfrs.jdb"; for (int i=1;i>%s\n",recbuff); }