Click to See Complete Forum and Search --> : Need help fast. PLEASEEEEEE!
kourosh
Nov 6th, 1999, 09:28 AM
Hi, I am creating an application which basicly show the name of the .rm files (Real Player) and then the user have to click one and then click the play button to play the file in the real player. Ok this is the problem I used a label to store the compete path to a variable name RPF then I used the shell command to play the path (Which is the label caption) using the shell command. Ok this is the code
Dim RPF as variant
RPF = lblmusic.caption
shell RPF
But I get a message saying the can not find path, it doesn't understand that RPF is a variable and it seppose to play the path inside the label. I need this program for monday please help me to complete the program I really appreciate if you show me an easy way to do so. I have to explain the codes to my teacher, so you know why I want it to be easy.
Thanks in Advance
Aaron Young
Nov 6th, 1999, 09:40 AM
OK, there's a couple of things..
I suspect that your Path stored in the Label contains a Directory Name which has a Space in it, eg. "Program Files", in which case Shell would try to Run the Text upto Program and Treat Files.. Etc as a Command Line. Or, your path doesn't include a File Name.
2nd, Shell doesn't run Files by Association, this means when you pass it the File with an "rm" extension it will Error.
What you need to use is the ShellExecute API which will Open a File with its associated Application and also enclose the Path and File name in Quotes, eg.
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
Private Sub Command1_Click()
ShellExecute 0, "OPEN", Chr(34) & lblMusic & Chr(34), "", "", 1
End Sub
Where lblMusic contains the Full Path and Name of the "rm" File, eg. C:\My Files\Music.rm"
------------------
Aaron Young
Analyst Programmer
aarony@redwingsoftware.com
adyoung@win.bright.net
kourosh
Nov 6th, 1999, 12:47 PM
Thanks alot but the code you provided me with didn't work.
:(
Aaron Young
Nov 6th, 1999, 01:47 PM
It should work fine as long as lblMusic Contains a Valid Path and File, I tested it with a RealPlayer File.
Why don't you Post the code you are trying to use and we can take a look.
------------------
Aaron Young
Analyst Programmer
aarony@redwingsoftware.com
adyoung@win.bright.net
Compwiz
Nov 7th, 1999, 11:04 AM
Some things to look for in a path (On Win32):
Must Have Back Slashes (\) and not Forward Slashes (/)
Make sure for the drive letter specification, you are using a colon, and not a semi-colom:
C:\ - Right
C;\ - Wrong
If the file is not an executable (.exe) then you must specify the extension:
C:\Music\MySong.rm - Right
C:\Music\MySong - Wrong (if not .exe)
If there is a space in the path, make sure you include it. (i.e. "C:\My Documents")
Just take a look at these and hope this might help.
------------------
Tom Young, 14 Year Old
tyoung@stny.rr.com
ICQ: 15743470
AIM: TomY10
PERL, JavaScript and VB Programmer
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.