I have a file which is exclusively opened by a Process A (a third party application). I obviously couldn't open the file in my application, so I thought of Duplicating the Handle using DuplicateHandle API.
However, I realized that the change in position of the file handle will also be reflected in Process A as well , which could cause undesired behaviour. Is there a way I can duplicate the file handle for reading, without affecting the file Handle (position) in Process A?
I finally figured it out:
Using the duplicate handle now CreateFileMapping handle and followed by MapViewOfFile . MapViewOfFile maps certain portion of the file to the your process address space and can be used to read the file without disturbing the current file offset of the of the original file handle.
Hope this helps someone.