BOOL GetLine(HANDLE hFile, LPTSTR lpstr, DWORD size)
{
DWORD numRead;
DWORD index = 0;
DWORD newline = 0;
TCHAR tc;
while(index < size - 1)
{
if(!ReadFile(hFile, &tc, 1, &numRead, NULL) || numRead == 0)
{
lpstr[index] = _T('\0');
return (index != 0);
}
else
{
if (tc == _T('\r') || tc == _T('\n'))
{
if(newline == 0) continue;
lpstr[index] = _T('\0');
return TRUE;
}
else
{
newline = 1;
lpstr[index++] = tc;
}
}
}
lpstr[index] = _T('\0');
return TRUE;
}