Problems handling .RES files
Hello, I have a problem handling .RES files in Visual Basic that I really hope you will help me to solve.
In particular, I cannot launch an embedded .AVI file after having compiled it by means of the Resource Compiler you can find in the VB CD-ROM.
The procedure I followed is the following:
1. I created an .RC file containing the following line of code:
101 AVI DISCARDABLE "TEST.AVI"
2. I embedded the .AVi file (TEST.AVI) into a resource file (TEST.RES) using RC.EXE.
3. I added TEST.RES to the VB project and placed the following code in the General Declarations window of Form1:
Private Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As Any, ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long
4. Finally, I typed the following code in the click event of a command button:
Private Sub cmdPlayAviRes_Click()
Dim RetValue As Long
Dim AviArray() As Byte
Dim strCmdStr As String
AviArray = LoadResData(101, "AVI")
strCmdStr = "play " & AviArray(0) & " "
RetValue = mciSendString(strCmdStr, 0&, 0, 0&)
The code above works perfectly, with some modifications, when dealing with .WAV files. Unfortunately, it seems not to work with .AVI files: clicking on the command button produces no results. Where did I make a mistake?
Thanks for your attention. I'm counting on your help.
Perugia - Italy
Silly question, perhaps, but do you have the necessary association for .AVI files on the target system? What happens if you double-click on an AVI file in Windows Explorer on the target PC?
July 10th, 2003, 12:53 PM
.AVI files are associated to Windows Media Player, on both the source and target computer.
To tell the truth, I have already found a way to work around the problem: first I import the .RES file containing the .AVI movie, then I save it in a temporary file on the hard disk and, finally, I delete it after having played it. What I don't like of this solution is the fact that I have to create a temporary file on the local computer: this slows down the execution of the movie which can only start after the temporary file has been created. That's why I am exploring the possibility of playing .AVI movies directly from the embedded .RES file. Do you know how - and if - it is possible?
July 10th, 2003, 01:39 PM
Sorry, no - you're way ahead of me in this area.
July 11th, 2003, 01:35 AM
No problem. Thank you anyway.