|
-
Jun 13th, 2003, 01:26 AM
#1
Thread Starter
Lively Member
How to find if a file is in use?
Hello,
Can any one tell me how do I find if a file is in use?
Thanks.
-
Jun 13th, 2003, 06:14 PM
#2
EnumWindows might help you if you wish to find a seperate process thats running.
enumprocess api
~
if a post is resolved, please mark it as [Resolved]
protected string get_Signature(){return Censored;}
[vbcode][php] please use code tags when posting any code [/php][/vbcode]
-
Jun 16th, 2003, 04:24 AM
#3
Thread Starter
Lively Member
Nope 'enumprocess' would not help.
The reason being 'enumprocess' would allow me to enumerate the currently running process list. But, how do I know which of the documents is being accessed by them.
Isn't there any API do check if any file is in use?
Thanks.
-
Jun 16th, 2003, 06:34 AM
#4
-
Jun 19th, 2003, 04:32 AM
#5
Addicted Member
-
Jun 19th, 2003, 08:19 AM
#6
-
Jun 25th, 2003, 01:18 AM
#7
Hyperactive Member
I found this in API-Guide
VB Code:
'Determine whether a file is already open or not
Private Declare Function lOpen Lib "kernel32" Alias "_lopen" (ByVal lpPathName As String, ByVal iReadWrite As Long) As Long
Private Declare Function lClose Lib "kernel32" Alias "_lclose" (ByVal hFile As Long) As Long
Private Function IsFileAlreadyOpen(FileName As String) As Boolean
Dim hFile As Long
Dim lastErr As Long
' Initialize file handle and error variable.
hFile = -1
lastErr = 0
' Open for for read and exclusive sharing.
hFile = lOpen(FileName, &H10)
' If we couldn't open the file, get the last error.
If hFile = -1 Then
lastErr = Err.LastDllError
Else
' Make sure we close the file on success.
lClose (hFile)
End If
' Check for sharing violation error.
sFileAlreadyOpen = (hFile = -1) And (lastErr = 32)
End Function
Private Sub Form_Load()
MsgBox IsFileAlreadyOpen("c:\autoexec.bat")
End Sub
-
Jun 27th, 2003, 09:52 AM
#8
Thread Starter
Lively Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|