[python-win32] Finding DLL's which are in use (loaded)
Aahz
aahz at pythoncraft.com
Thu Apr 8 20:51:59 CEST 2010
On Wed, Apr 07, 2010, Tony Cappellini wrote:
>
> I need to write a program which copies some dlls from one location
> to another. However, if any applications which use these dll's are
> running, Windows won't let the dll copy complete, until the apps
> which have the dlls loaded have terminated. I'm looking for a way
> to scan/probe to see if any apps are running which have these dll's
> loaded. How would I go about this with Python ?
Here's my company's code:
# Open file in read-only exclusive mode, then immediately close; if anything
# has the file open, will fail
h = win32file.CreateFileW(
fname,
win32file.GENERIC_READ,
0, # exclusive access
None, # no security attrs
win32file.OPEN_EXISTING,
win32file.FILE_FLAG_NO_BUFFERING,
None
)
h.Close()
--
Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/
"...string iteration isn't about treating strings as sequences of strings,
it's about treating strings as sequences of characters. The fact that
characters are also strings is the reason we have problems, but characters
are strings for other good reasons." --Aahz
More information about the python-win32
mailing list