Hello Eric,
The programtical solution to this problem would probably mean looking
for open handles. The ZwQuerySystemInformation api using the
SystemHandleInformation will allow you to enumerate handles and will
give you the PID of the owning process. You will find it exported from
ntdll.dll.
Regards,
Anders Fogh
P.s. If you do write such a program - please send me a copy… you’re
not the only one with such problems.
Thursday, March 01, 2001, 8:57:25 AM, you wrote:
SE> I must apologize… I used a bad example when I picked a DLL file name.
SE> I suspect most of us are familiar with the “sysinternals” utilities. And
SE> while they are quite useful for finding out which application is currently
SE> holding onto a DLL or program file, there are situations where a general
SE> purpose “Who’s got this file open” utility would be better – a utility that
SE> would tell you which program has “readme.txt” open.
SE> During my normal everyday usage of Windows I delete directories or lists of
SE> files. Sometimes Explorer tells me that it can’t comply because one or more
SE> of the files or directories I’m deleting are currently being used. (Let’s
SE> ignore the brain-dead behavior Explorer itself exhibits if IT happens to be
SE> the application that currently has a directory open.) Sometimes this file is
SE> a DLL, but sometimes, it’s not. I can use a sysinternals utility if it’s a
SE> DLL, but if it’s not… well.
SE> The best behavior I could expect from a file utility would be an error
SE> message that tells me WHICH file or directory can’t be deleted, and WHICH
SE> application or process is holding that file open so that I could go ahead
SE> and close that application and finish what I was doing. Instead, I play a
SE> game of “guess which application needs this file”. That game is fun for the
SE> first 3 seconds, but quickly becomes tedious as I make my way through Task
SE> Manager’s 100+ item running process list.
SE> My real question is, somewhere in the file system, the network apis, the
SE> system objects table, or the kernel, somebody knows who has that file open.
SE> How do I get to that information so that I can write a replacement for
SE> Explorer that does the proverbial “right thing”?
SE> ERX
> -----Original Message-----
> From: Danilo Almeida [mailto:xxxxx@MIT.EDU]
> Sent: Thursday, March 01, 2001 11:27 AM
> To: NT Developers Interest List
> Subject: [ntdev] RE: Problem on deleting file
>
>
> Here are a couple of useful commad-line utilities:
> http://www.sysinternals.com/ntw2k/freeware/listdlls.shtml
> http://www.sysinternals.com/ntw2k/freeware/handle.shtml
>
> For a GUI one that combines both:
> http://www.sysinternals.com/ntw2k/freeware/handleex.shtml
>
> - Danilo
>
> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com]On Behalf Of Steadle, Eric
> Sent: Thursday, March 01, 2001 10:39 AM
> To: NT Developers Interest List
> Subject: [ntdev] RE: Problem on deleting file
>
>
> This just begs the question… how does one find out which
> application is
> holding a file open. Sometimes it’s obvious (*.doc is
> probably MSWord). But
> sometimes it’s not (msvc42.dll). There’s got to be an API, right?
>
> ERX
>
>
>
> > -----Original Message-----
> > From: Stas Desy [mailto:xxxxx@powernetsys.com]
> > Sent: Wednesday, February 28, 2001 7:32 AM
> > To: NT Developers Interest List
> > Subject: [ntdev] RE: Problem on deleting file
> >
> >
> > You can’t. The file will be locked by the OS.
> > You must know what application is using it. If an application
> > thread that is
> > using the file fails to exit you can go to the task manager
> > and kill the
> > process.
> >
> >
> > -----Original Message-----
> > From: xxxxx@lists.osr.com
> > [mailto:xxxxx@lists.osr.com]On Behalf Of Ricky Villegas
> > Sent: Wednesday, February 28, 2001 11:54 AM
> > To: NT Developers Interest List
> > Subject: [ntdev] Problem on deleting file
> >
> >
> > To all:
> >
> > Im trying to delete a file (it has a normal attribute), and
> > an error occurred like this:
> > “ACCESS DENIED. FILE MAY BE IN USE.”
> > How can I delete this file w/o knowing which application used
> > this file?
> >
> > thanks in advance,
> > -Rick-
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@mediasite.com
> To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com
>
SE> —
SE> You are currently subscribed to ntdev as: xxxxx@flaffer.com
SE> To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com
–
Best regards,
Anders mailto:xxxxx@flaffer.com
You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com