Update: it suffice to open the file with CreateFile(...,FILE_FLAG_NO_BUFFERING,...). Other apps (also the same app) re-read the content of the file until the file handle is closed.
Remark: If you want to read the file in the same app, use second handle i.e..:
hd_unbuf = CreateFile( filename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_NO_BUFFERING, NULL );
while( true )
{
hd = CreateFile( filename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL );
if( hd != (HANDLE)-1 )
{
memset ( buf, 0x00, sizeof(buf) );
//SetFilePointer ( hd, 0, 0, FILE_BEGIN );
ReadFile( hd, buf, 10, &bytes, NULL );
if ( bytes > 0 )
std::cout << buf << std::endl;
CloseHandle( hd );
Sleep( 1000 );
}
else
std::cout << "Error: " << GetLastError() << std::endl;
}
CloseHandle( hd_unbuf );