www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - How to terminate a file in use?

reply a.c.edwards <a.c.edwards_member pathlink.com> writes:
Gentlemen,
I'm wondering if you can point me in the right direction. Need to know how to
check if a file is in use and forcedly terminate it.

Thanks,
Andrew
Dec 24 2005
parent reply Manfred Nowak <svv1999 hotmail.com> writes:
a.c.edwards wrote:

 I'm wondering if you can point me in the right direction.

At this time of the year there is only one direction to follow, which is pointed out here: http://www.griffithobs.org/StarofBethlehem.html On this way you may want to pause at http://www.mstsoftware.com/c_mst_IsUsedBy_d.aspx But there might not be any possibility to terminate christianity or the files used by them. -manfred
Dec 24 2005
parent reply a.c.edwards <a.c.edwards_member pathlink.com> writes:
Thanks, Manfred. Unfortunately though, the proxy server was being a prick and
flat out denied my request to stop at:

http://www.mstsoftware.com/c_mst_IsUsedBy_d.aspx

In article <Xns9736CB8E03E59svv1999hotmailcom 63.105.9.61>, Manfred Nowak
says...
a.c.edwards wrote:

 I'm wondering if you can point me in the right direction.

At this time of the year there is only one direction to follow, which is pointed out here: http://www.griffithobs.org/StarofBethlehem.html On this way you may want to pause at http://www.mstsoftware.com/c_mst_IsUsedBy_d.aspx But there might not be any possibility to terminate christianity or the files used by them. -manfred

Dec 25 2005
parent reply Manfred Nowak <svv1999 hotmail.com> writes:
a.c.edwards wrote:

 Thanks, Manfred. Unfortunately though, the proxy server was
 being a prick and flat out denied my request to stop at:

I am quite sure the the great being, who controls all of us at this time of the year, will soon forgive all pricks what they are doing to you now. Meanwhile simple try one of the 10,000 hits your favorite internet search engine will give out on a request for "mst isusedby". Have some more nice days with your family. -manfred
Dec 25 2005
parent reply a.c.edwards <a.c.edwards_member pathlink.com> writes:
Once again, thank you very much. This is not exactly what I'm looking for
though. I'm run a program that analyzes several reports and output the results
to RTF documents that may or may not already exist. However, the program
prematurely terminates if any of the preexisting documents are in use.

I'd like to check to see if the file is in use by a different process and then
issue a close request to that process. I'm sure it is possible just not sure
what the exact API function call is. Closest thing I can find in windows.d is
FileClose() but it doesn't exactly foot the bill.

Andrew

In article <Xns9737C6011EE63svv1999hotmailcom 63.105.9.61>, Manfred Nowak
says...
a.c.edwards wrote:

 Thanks, Manfred. Unfortunately though, the proxy server was
 being a prick and flat out denied my request to stop at:

I am quite sure the the great being, who controls all of us at this time of the year, will soon forgive all pricks what they are doing to you now. Meanwhile simple try one of the 10,000 hits your favorite internet search engine will give out on a request for "mst isusedby". Have some more nice days with your family. -manfred

Dec 26 2005
parent reply Manfred Nowak <svv1999 hotmail.com> writes:
a.c.edwards wrote:

[...]
 I'd like to check to see if the file is in use by a different
 process and then issue a close request to that process.

I believe, that this is not possible in general and especially for Windows. Otherwise Windows would give some hint for users who want to delete a file in use, which is the main focus of "mst isusedby" and especially would never request restarts, because files are in use during an installation. If you try out "mst isusedby" you will find, that it needs a long time to mostly not displaying some usable for your request. I am quite sure that once you have found out the reasons for that behaviour, which is surely best done through a microsoft news group or one of your two free technical support tickets you will be able to solve this problem on your own using your aparently good knowledge of D. I thank you in advance for then pointing me to the answer you have found for this known mysterium. Again I wish you some nice days with your family. -manfred
Dec 26 2005
next sibling parent reply a.c.edwards <a.c.edwards_member pathlink.com> writes:
In article <Xns97386EBF4B3A8svv1999hotmailcom 63.105.9.61>, Manfred Nowak
says...
a.c.edwards wrote:

[...]
 I'd like to check to see if the file is in use by a different
 process and then issue a close request to that process.

I believe, that this is not possible in general and especially for Windows. Otherwise Windows would give some hint for users who want to delete a file in use, which is the main focus of "mst isusedby" and especially would never request restarts, because files are in use during an installation. If you try out "mst isusedby" you will find, that it needs a long time to mostly not displaying some usable for your request. I am quite sure that once you have found out the reasons for that behaviour, which is surely best done through a microsoft news group or one of your two free technical support tickets you will be able to solve this problem on your own using your aparently good knowledge of D.

I think you might have me mixed up with someone else. My programming ability is hapenstance in motion hence knowledge != skill. I will keep trying but my current location does not give my that flexibility to search the necessary forums.
I thank you in advance for then pointing me to the answer you have 
found for this known mysterium.

Since I'm behind the Iron Curtain of proxy denial, this might have to be postponed until I return to the US but I will definately pass on what I find.
Again I wish you some nice days with your family.

-manfred

Dec 26 2005
parent Manfred Nowak <svv1999 hotmail.com> writes:
a.c.edwards wrote:

[...]
 Since I'm behind the Iron Curtain of proxy denial, this might
 have to be postponed until I return to the US but I will
 definately pass on what I find. 

Thank you. And one last idea on this problem: is it tolerable to do what Windows mostly does in such cases, i.e. switch to running your program at startup? -manfred
Dec 26 2005
prev sibling parent Manfred Nowak <svv1999 hotmail.com> writes:
Manfred Nowak wrote:

[...]
 I believe, that this is not possible in general and especially
 for Windows.

http://www.sysinternals.com/Utilities/Handle.html has another tool for finding the processes that own a handle with the explicit "WARNING: Closing handles can cause application or system instability." -manfred
Dec 26 2005