The AVIFileOpen function opens an AVI file and returns the address of a file interface used to access it. The AVIFile library maintains a count of the number of times a file is opened, but not the number of times it was released. Use the AVIFileRelease function to release the file and decrement the count.
Declare Function AVIFileOpen Lib "avifil32" Alias "AVIFileOpenA" (ppfile As Long, ByVal szFile As String, ByVal mode As Long, pclsidHandler As Any) As Long
Address to contain the new file interface pointer.
Null-terminated string containing the name of the file to open.
Access mode to use when opening the file. The default access mode is OF_READ. The following access modes can be specified with AVIFileOpen:
Creates a new file. If the file already exists, it is truncated to zero length.
Opens the file nonexclusively. Other processes can open the file with read or write access. AVIFileOpen fails if another process has opened the file in compatibility mode.
Opens the file nonexclusively. Other processes can open the file with write access. AVIFileOpen fails if another process has opened the file in compatibility mode or has read access to it.
Opens the file nonexclusively. Other processes can open the file with read access. AVIFileOpen fails if another process has opened the file in compatibility mode or has write access to it.
Opens the file and denies other processes any access to it. AVIFileOpen fails if any other process has opened the file.
Opens the file for reading.
Opens the file for reading and writing.
Opens the file for writing.
Address of a class identifier of the standard or custom handler you want to use. If the value is NULL, the system chooses a handler from the registry based on the file extension or the RIFF type specified in the file.
Returns zero if successful or an error otherwise. Possible error values include the following:
The file couldn’t be read, indicating a corrupt file or an unrecognized format.
The file could not be opened because of insufficient memory.
A disk error occurred while reading the file.
A disk error occurred while opening the file.
According to the registry, the type of file specified in AVIFileOpen does not have a handler to process it.
Private Const OF_SHARE_DENY_WRITE As Long = &H20
Private Type AVIFILEINFO
dwMaxBytesPerSec As Long
dwFlags As Long
dwCaps As Long
dwStreams As Long
dwSuggestedBufferSize As Long
dwWidth As Long
dwHeight As Long
dwScale As Long
dwRate As Long
dwLength As Long
dwEditCount As Long
szFileType As String * 64
Private Declare Function AVIFileOpen Lib "avifil32" Alias "AVIFileOpenA" (ppfile As Long, ByVal szFile _ As String, ByVal mode As Long, pclsidHandler As Any) As Long
Private Declare Function AVIFileRelease Lib "avifil32" (ByVal pfile As Long) As Long
Private Declare Function AVIFileInfo Lib "avifil32" Alias "AVIFileInfoA" (ByVal pfile As Long, pfi As _ AVIFILEINFO, ByVal lSize As Long) As Long
Private Declare Sub AVIFileInit Lib "avifil32" ()
Private Declare Sub AVIFileExit Lib "avifil32" ()
Private Sub Form_Load()
Dim hFile As Long, AviInfo As AVIFILEINFO
If AVIFileOpen(hFile, "C:\\SIERRA\\Half-Life\\valve\\media\\sierra.avi", OF_SHARE_DENY_WRITE, _
ByVal 0&) = 0 Then
If AVIFileInfo(hFile, AviInfo, Len(AviInfo)) = 0 Then
MsgBox "AVI dimensions: " + CStr(AviInfo.dwWidth) + "x" + CStr(AviInfo.dwHeight)
MsgBox "Error while retrieving AVI information... :("
MsgBox "Error while opening the AVI file... :("