[python-win32] Finding DLL's which are in use (loaded)

Jeremy Nicoll - ml pyw32 jn.ml.pyw32.88 at wingsandbeaks.org.uk
Mon May 3 22:28:44 CEST 2010


Tony Cappellini <cappy2112 at gmail.com> 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 ?

I might be inclined to use something else, for example SysInternals'
'handle' program.  Here for example executing

  handle -a .dll

looks for all handles that are for something which includes ".dll" in its
name.  Here, now, for example, that gives:

System             pid: 4       350: C:\WINDOWS\system32\ntdll.dll

lsass.exe          pid: 740      8C:
HKLM\SYSTEM\ControlSet005\Control\Lsa\SspiCache\msapsspc.dll

lsass.exe          pid: 740      90:
HKLM\SYSTEM\ControlSet005\Control\Lsa\SspiCache\msnsspc.dll

lsass.exe          pid: 740      98:
HKLM\SYSTEM\ControlSet005\Control\Lsa\SspiCache\digest.dll

Dropbox.exe        pid: 2828    534: C:\WINDOWS\system32\hnetcfg.dll

(as those lines were too long for my email client's write window, and
wrapped, I've spaced them out)

Executing the handle command and redirecting its output to a file which you
then read might work for you.  

-- 
Jeremy C B Nicoll - my opinions are my own.



More information about the python-win32 mailing list