Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Close Running Application

Status
Not open for further replies.

HydraNL

Technical User
May 9, 2005
74
NL
hi,
How do I know if the application is running and how do I close a running application?

Example: Let's say that C:\test.txt is already open, but you aren't aware. If I want to replace that file or remove that file you'll fail.

Thanks in advance.

 
Placing
Code:
Close
on a line by itself will close all files which your program opened using the Open statement.
 
Ok. But how do I tell VB: If file-is-in-use then close.
 
Initially, you need to know whether the file is open or not. One way of doing this is to use the CreateFile API with the exclusive access flag set. If you get a valid file handle, the file is closed otherwise the file is open.

Personally, I wouldn't seek to close the process which has the file open, I would wait until the file is closed and then update.

Take Care

Matt
If at first you don't succeed, skydiving is not for you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top