Doug Hale wrote: > I have some log files that I want to monitor in real-time. The files can > be opened by Notepad but I have not been able to open them it a delphi > program. The error says the file is being used by another process. I > have tried opening the file with TFileStream with fmOpenRead, > fmShareDenyNone. > > What do I need to do to read a file that is currently being written by > another process? I know it can be done because Notepad can do it.
Use Process Monitor to watch the system calls that notepad makes when you open the file. Find the one that creates the file (IRP_MJ_CREATE), and then use the same flags when you call CreateFile. Once you have the handle from CreateFile, use THandleStream to wrap a Delphi stream around it. -- Rob

