Описание слайда:
ФУНКЦІЇ ДЛЯ РОБОТИ З ПОКАЗНИКАМИ. ПРИКЛАД 3.4
Отримання запису по його номеру
size_t ReadDBRecord (TCHAR *DBName, TCHAR *DBIndex, size_t i, TCHAR * Rec){
size_t res = 0; DWORD dwCount;
HANDLE h1 = CreateFile (DBName, GR, FSR, 0, OE, 0, 0),
h2 = CreateFile (DBIndex, GR, FSR, 0, OE, 0, 0);
BOOL b = h1!= IHV && h2 != IHV;
if (b){
DWORD dwRecs = GetFileSize (h2, 0) / sizeof (size_t);
b = dwRecs > i;
if (b){
size_t offset; SetFilePointer (h2, i * sizeof (size_t), 0, FILE_BEGIN);
b = ReadFile (h2 ,&offset, sizeof (size_t), &dwCount, 0);
if (b){
SetFilePointer (h1, offset, 0, FILE_BEGIN);
b = ReadFile (h1, &res, sizeof (size_t), &dwCount, 0);
}
if (b && Rec != 0) b = ReadFile (h1, Rec, res, &dwCount, 0);
}
}
if (h1) CloseHandle (h1); if (h2) CloseHandle (h2);
return res;}