Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problems with ShellExecute 2

Status
Not open for further replies.

webpager

Programmer
Mar 27, 2001
166
GB
I am attempting to load an MP3 file into winamp from within VFP. I have taken the syntax from the Universal Thread example as below.

DECLARE integer ShellExecute IN Shell32.dll ;
INTEGER HWND;
STRING lpverb;
STRING lpfile;
STRING lpPrameters;
STRING lpDirectory;
LONG nshowcmd

No errors with the declaration but the following line returns an error.

=SHELLEXECUTE((hand1),"open","d:\sounds\allnight.mp3","","",0)

ERROR
"Cannot find entry point shellexecute in the DLL"

Questions
1. What causes the error?
2. Is there a more suitable API function for this purpose?
3. Does ShellExecute support "LOAD" as a verb
 
Hello, try this
DECLARE integer ShellExecute IN Shell32.dll INTEGER,; STRING@,STRING@,STRING@,string@,LONG
Declare Integer GetDesktopWindow in Win32api

cmd = "open"
mfile = "c:\OnlyYou.mp3" && make sure that this file exist
hwnd = GetDesktopWindow()

?ShellExecute(hwnd,@cmd,@mfile,NULL,NULL,0)


I haved tried and succeeded





Jimmy Le
nhan_tiags@yahoo.com
 
You could simply do
Code:
! /n winamp d:\sounds\allnight.mp3

if all you want is to open the file in winamp?
 
Hi WP,

1. API functions are case-sensitive. So, typically, the culprit of a "Cannot find entry point XXX in the DLL" error is a misdeclared function. FYI - this error will not be generated until you attempt to call the function, as per your comments.

2. No, you are using the most appropriate method, IMO. Alternatively, you could use Chris's recommendation and use the RUN command. But that limits the file to being opened with Winamp. Using the Shell allows the file to be opened with whatever the user's default mp3 player is, allbeit, Windows Media Player, RealPlayer, etc...

3. No. FWIW, I'd recommend you read the following article by Rick Strahl:
paying particular attention to the section labeled "The Shell API" where he gives a brief intro to the Shell. Additionally, refer to the MSDN for more information on ShellExecute. Jon Hawkins

The World Is Headed For Mutiny,
When All We Want Is Unity. - Creed
 
I have found the info supplied by this forum very helpful. My experiments have taken me into a whole new area where I did not intend to go but curiosity has driven me on.
The problem with ShellExecute was that I wasn`t using values rather than references, a small but fatal error.
Once I was able to play a single MP3 file I experimented with playing multiple files. Using the ShellExecute method proved a problem, I could play 1 file no problem but a second file was added to the first window rather than into a new one. Using Chris`s suggestion (RUN /n etc.) proved more successful. I set about playing numerous files and stopped at 8 because I couldn`t see any point in being able to play more. I get the window handle, after the file has started. It would be better if the window handle could be obtained before the file plays but I am unsure if that would be possible. At the momment, I start the file using RUN /n etc. but have the volume turned down, get the window handle, pause it and then turn the volume up ready for playing. It sounds messy but works a treat and only takes a second or so on my less than state of the art machine.
My next step is to use the stopwatch to control an event handler which should allow me to obtain info such as track position, time remaining and such like. If I can event handle 3 files at once then there is light at the end of the tunnel. Just how robust this program will be remains to be seen but I am hopeful. My only concern is losing file handles somewhere along the way but I have created a PANIC routine which closes all active Winamp windows at once.
Thanks for the help and I am sure there will be more problems in the future.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top