1
|
2
******************************************************
********************************************************
******************************************************
'************** WinAPI function **************
'http://www.shrinkwrapvb.com/avihelp/avihlp_1.htm
'Feel free to replace cFileDlg.cls class with the VB Common Dialog ocx if
' you really want to
'The AVIFileOpen function accepts the same OF flags as the OpenFile API
' function
Dim res As Long
'result code
Dim ofd As cFileDlg 'OpenFileDialog
class
Dim szFile As String
'filename
'Get the name of an AVI file to
work with
Set ofd = New cFileDlg
With ofd
.OwnerHwnd = Me.hWnd
.Filter = "AVI Files|*.avi"
.DlgTitle = "Open AVI File"
End With
res = ofd.VBGetOpenFileName(szFile)
If res = False Then GoTo ErrorOut
ErrorOut:
If pAVIFile <> 0 Then
Call AVIFileRelease(pAVIFile)
'// closes the file
End If
If (rc <> AVIERR_OK) Then 'if
there was an error then show feedback to user
MsgBox "There was an error working with the file:" _
& vbCrLf & szFile, vbInformation, App.Title
End If
'******************************************
For our simple test program, put the following line of code in Form_Load:
Call AVIFileInit '// opens AVIFile library
And put the following line of code in Form_Unload:
Call AVIFileExit '// releases AVIFile library
'******************************************
The next step is to be able to open the AVI file that the user selects from the common dialog and get a PAVIFILE handle which can be passed to other AVIFile functions as necessary. We use the AVIFileOpen function to do this. Add these 2 lines of code to the command button click event
Dim pAVIFile as Long
'pointer to AVI File (PAVIFILE handle)
res = AVIFileOpen(pAVIFile, szFile, OF_SHARE_DENY_WRITE,
0&)