[python-win32] Open files, round 2
Aahz
aahz at pythoncraft.com
Tue Nov 24 03:00:24 CET 2009
On Mon, Nov 23, 2009, Aahz wrote:
>
> I'm having some problems with Tim Golden's file_handles.py [*] (details
> below), and it occurs to me that perhaps I should start over and express
> my requirement more broadly and see if someone has a more "Windows
> appropriate" solution: all I really care about is, given a specific
> filepath, whether any other program is currently using the file.
>
> This would work:
>
> h = win32file.CreateFile(fname, win32file.GENERIC_READ, 0, None,
> win32file.OPEN_EXISTING, win32file.FILE_FLAG_NO_BUFFERING, None)
>
> but I would prefer not to create an exclusive lock, even temporarily.
> Suggestions?
Okay, because of the following page (plus supporting material found
elsewhere), it seems clear that in order to find open files, you need a
device driver to access kernel structures, so I just switched to using
CreateFile() and so far that seems to be working.
http://www.codeproject.com/KB/shell/OpenedFileFinder.aspx
--
Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/
The best way to get information on Usenet is not to ask a question, but
to post the wrong information.
More information about the python-win32
mailing list