Aahz wrote:
On Fri, Oct 23, 2009, Tim Golden wrote:
Aahz wrote:
I'm just getting into Windows programming for the first time, and I need
to list all open files.  Windows has a convenient function for that
(NtQuerySystemInformation), but I can't figure out how I am supposed to
call it.  I bought of copy of the Win32 book and I can't find anything
about accessing random API calls;
ctypes.windll.kernel32.NtQuerySystemInformation gives an AttributeError.

Where should I be looking to figure this out?
To answer your question slightly obliquely, can I offer you:

http://winsys.googlecode.com/svn/trunk/random/file_handles.py

Wow!  Thanks!  Now that I know more what to look for, I did some
searching and found this post that had no response:

http://mail.python.org/pipermail/python-win32/2009-June/009268.html

Assuming that I only care about monitoring open files within a single
tree, should I be concerned that your code might not return all open
files?

Have to confess that I don't usually work at this level, and as others
have pointed out, this is undocumented stuff... The de facto authority
is sysinternals, but none of that is Open Source so I don't really
know why their handle.exe picks up more files than my code. :(
I was sort of hoping that someone like Tim Roberts -- who works
with device drivers -- would have a hint.

Obviously, the answer would depend on the parameters of what you're
trying to do and how much margin of error you have. One definite
gotcha I wasn't totally able to work around -- although the code in
can_access is trying -- is the issue that attempting to query for
a pipe handle can hang the thread altogether. I believe that the
poster in the thread you refer to above didn't have any such problem
(we had a private correspondence which led up to that post).


If you believe that your C++ code is definitely working and you're
free to post it up, I for one am happy to help you translate it.
Maybe that's an option...

TJG

PS Welcome to the world of Python on Windows!
_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to