How can I access the files that are in-use by other processes. Say there is this file called "locked.txt", which is in use by process A. Now how can I copy this file to another location programmatically. Normal methods will fail with the error "The process cannot access the file because it is being used by another
process.".
Any ideas ?
look on the forum, hutch posted code to do this.
Quotelook on the forum, hutch posted code to do this.
Can't find it.
shakuni,
For non-system files such as log files that are repeatedly being written to this method works OK in many instances but it will not open specialised system files.
invoke CreateFile,OFFSET logbuffer,GENERIC_READ,
FILE_SHARE_WRITE or FILE_SHARE_READ,
NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL or \
FILE_FLAG_POSIX_SEMANTICS,NULL
mov hFile, eax
The action is with the "FILE_FLAG_POSIX_SEMANTICS" flag as it changes the file access rules to asically Unix rules.
Try also if there is a diff between using and not using FILE_SHARE_WRITE. Normally you would not need write access.
Attention FILE_FLAG_POSIX_SEMANTICS makes file names case-sensitive.
I assume you have tested a simple CopyFileA?
You could be interested with the following link : http://technet.microsoft.com/en-us/sysinternals/default.aspx?PHPSESSID=9692e6
Perhaps you saw it...