|
|
|
Click here to copy the following block | 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 IsFileOpened(FileName As String) As Boolean Dim hFile As Long Dim lastErr As Long hFile = -1 lastErr = 0 hFile = lOpen(FileName, &H10) If hFile = -1 Then lastErr = Err.LastDllError Else lClose (hFile) End If IsFileOpened = (hFile = -1) And (lastErr = 32) End Function
Private Sub Form_Load() On Error GoTo errhandler Dim Handle As Long Dim FileName As String
FileName = "c:\autoexec.bat" Handle = FreeFile If IsFileOpened(FileName) Then MsgBox FileName & " is Opened by someone" Else MsgBox FileName & " is closed" End If Exit Sub errhandler: MsgBox Err.Description End Sub |
|
|
|
Submitted By :
Nayan Patel
(Member Since : 5/26/2004 12:23:06 PM)
|
|
|
Job Description :
He is the moderator of this site and currently working as an independent consultant. He works with VB.net/ASP.net, SQL Server and other MS technologies. He is MCSD.net, MCDBA and MCSE. In his free time he likes to watch funny movies and doing oil painting. |
View all (893) submissions by this author
(Birth Date : 7/14/1981 ) |
|
|