|
|
|
|
|
Dicas
|
|
Visual Basic (Imagem/Som/Multimídia)
|
|
|
Título da Dica: Executando videos AVI de resource files(RES)
|
|
|
|
Postada em 19/10/2003 por ^HEAVY-METAL^
'É necessário ter um controle animation em 'seu form !!!
Private Declare Function GetTempFileNameAPI Lib "kernel32" Alias "GetTempFileNameA" (ByVal lpszPath As String, ByVal lpPrefixString As String, ByVal wUnique As Long, ByVal lpTempFileName As String) As Long
Private Declare Function GetTempPathAPI Lib "kernel32" Alias "GetTempPathA" (ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long
Public Function GetTempPath() As String Dim Buffer As String 'Get Temporary path Buffer = Space(255) GetTempPathAPI Len(Buffer), Buffer GetTempPath = Left(Buffer, InStr(Buffer, Chr(0)) - 1) End Function
Public Function GetTempFileName(Prefix As String) As String Dim Buffer As String 'Create Temporary file Buffer = Space(255) GetTempFileNameAPI GetTempPath, Prefix, 0, Buffer GetTempFileName = Left(Buffer, InStr(Buffer, Chr(0)) - 1) End Function
Public Sub LoadVideo(AniCtrl As Animation, ResourceID As Long) Dim ByteData() As Byte Dim Fh As Long Dim TempFile As String 'Load Animation ByteData = LoadResData(ResourceID, "CUSTOM") 'Write animation To a temporary file Fh = FreeFile TempFile = GetTempFileName("ANI") Open TempFile For Binary Access Write As Fh Put Fh, , ByteData Close Fh 'Open animation And play AniCtrl.Open TempFile AniCtrl.Play End Sub
Private Sub Command1_Click() LoadVideo Animation1, 107 End Sub
Private Sub Form_Unload(Cancel As Integer) 'clear up any temporary files Animation1.Stop Animation1.Close Kill GetTempPath & "ANI*.tmp" End Sub
|
|
|
|
|