close handle of opened file

  • Thread starter Thread starter The Clansman
  • Start date Start date
T

The Clansman

is there any way to close a handle of a file in use?
I want to delete some files but some of them may be in use, and I need to
delete it anyway.


is it possible?

Thanks
 
Yeah, use the MoveFileEx API function with the delay until reboot constant.
Like So:

Private Const MOVEFILE_DELAY_UNTIL_REBOOT = &H4

Private Declare Function MoveFileEx Lib "kernel32" Alias "MoveFileExA"
(ByVal lpExistingFileName As String, ByVal lpNewFileName As String, ByVal
dwFlags As Int32) As Int32

Usage:

MoveFileEx([Filename including full path], vbNullString,
MOVEFILE_DELAY_UNTIL_REBOOT)

I hope this helps
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top