• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 142
  • Last Modified:

Opening a RealVideo file in a VB application

Hi,
 I would like to make some sort of interactive picture library. But I would also like to add some videos in it. I compressed them in Real Video but I can't make them play from a VB application. All I want is a command_Button that open RealPlayer and AUTOMATICALLY starts playing my Video.
Thanks
Mike,
0
mikezk
Asked:
mikezk
  • 2
1 Solution
 
VbmasterCommented:
You can use the ShellExecute API, add this code to your form (if you want to add it to a modal just replace the Private to Public).


Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

Function Run(ByVal strFilePath As String, ByVal strParms As String, ByVal strDir As String) As String
       
  'Run the Program and Evaluate errors
  Select Case ShellExecute(0, "Open", strFilePath, strParms, strDir, SW_SHOW)
  Case 0
    Run = "Insufficent system memory or corrupt program file"
  Case 2
    Run = "File not found"
  Case 3
    Run = "Invalid path"
  Case 5
    Run = "Sharing or Protection Error"
  Case 6
    Run = "Seperate data segments are required for each task"
  Case 8
    Run = "Insufficient memory to run the program"
  Case 10
    Run = "Incorrect Windows version"
  Case 11
    Run = "Invalid program file"
  Case 12
    Run = "Program file requires a different operating system"
  Case 13
    Run = "Program requires MS-DOS 4.0"
  Case 14
    Run = "Unknown program file type"
  Case 15
    Run = "Windows program does not support protected memory mode"
  Case 16
    Run = "Invalid use of data segments when loading a second instance of a program"
  Case 19
    Run = "Attempt to run a compressed program file"
  Case 20
    Run = "Invalid dynamic link library"
  Case 21
    Run = "Program requires Windows 32-bit extensions"
  Case Else
    Run = ""
  End Select

End Function

Now whenever you want to run a file that is associated with RealPlayer you can use the code

  Me.Caption = Run(Filename, "", "")

This will execute whatever program that is associated with the file extension of filename so you can use this code for any other file too. The function will return a empty string if everything went okay, if not it will return a string with a short description of what went wrong.




0
 
mikezkAuthor Commented:
When I insert this fonction into my program and that I try to execute Me.caption = ("e:\video.ra","","") VB says that SW_SHOW is not declared.
Thanx
Michael
0
 
VbmasterCommented:
Oh i missed that one, add

Private Const SW_SHOW = 5

where you declared the ShellExecute API.
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now