News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Accessing "in Use" Files == ?

Started by shakuni, May 14, 2008, 05:46:19 AM

Previous topic - Next topic

shakuni

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 ?

ecube

look on the forum, hutch posted code to do this.

shakuni

Quotelook on the forum, hutch posted code to do this.
Can't find it.

hutch--

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.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

jj2007

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?

Grincheux

Kenavo

Grincheux
_____________________________________________________
http://www.phrio.biz