06-09-2009, 08:39 AM
Can you convert this function to QM?
Private Function IsFileInUse(sFile As String) As IsFileResults
Dim hFile As Long
If FileExists(sFile) Then
'note that FILE_ATTRIBUTE_NORMAL (&H80) has
'a different value than VB's constant vbNormal (0)!
hFile = CreateFile(sFile, _
GENERIC_READ, _
0, 0, _
OPEN_EXISTING, _
FILE_ATTRIBUTE_NORMAL, 0&)
'this will evaluate to either
'-1 (FILE_IN_USE) or 0 (FILE_FREE)
IsFileInUse = hFile = INVALID_HANDLE_VALUE
CloseHandle hFile
Else
'the value of FILE_DOESNT_EXIST in the Enum
'is arbitrary, as long as it's not 0 or -1
IsFileInUse = FILE_DOESNT_EXIST
End If
Private Function IsFileInUse(sFile As String) As IsFileResults
Dim hFile As Long
If FileExists(sFile) Then
'note that FILE_ATTRIBUTE_NORMAL (&H80) has
'a different value than VB's constant vbNormal (0)!
hFile = CreateFile(sFile, _
GENERIC_READ, _
0, 0, _
OPEN_EXISTING, _
FILE_ATTRIBUTE_NORMAL, 0&)
'this will evaluate to either
'-1 (FILE_IN_USE) or 0 (FILE_FREE)
IsFileInUse = hFile = INVALID_HANDLE_VALUE
CloseHandle hFile
Else
'the value of FILE_DOESNT_EXIST in the Enum
'is arbitrary, as long as it's not 0 or -1
IsFileInUse = FILE_DOESNT_EXIST
End If