Passing flags to program via ShellExecute

I am writing a program to manage my mp3 playlists, i have currently got it to open a playlist for an album - although i can only open 1 album at a time. I would like to pass the option to enqueue files aswell as opening one set at a time. Looking at the winamp exe i need to call [winamp.exe] /ADD [file name for playlist].

i currently use
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

this function like this....

ShellExecute 0, "Open", sPlaylists.Item(List1.ListIndex + 1), "", "", SW_SHOW

but i would also like to pass the "/ADD" flag to append to the playlist.

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jaime OlivaresSoftware ArchitectCommented:
I suggest you to use WinExec instead:

Declare Function WinExec Lib "kernel32" Alias "WinExec" (ByVal lpCmdLine As String, ByVal nCmdShow As Long) As Long

WinExec("your command and arguments and flags here", 1)

Don't forget to give correct exe's full path

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
scanadminAuthor Commented:
thanks for your fast reply,

is there no way to do it without the full path as with shellexecute. i am planning to make the application and distribute it over the web so out like it to run with the default players.

If the default player is not winamp, then do you still want to pass the /ADD switch?
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Jaime OlivaresSoftware ArchitectCommented:
If you want to pass multiple files or some switches, then you have to call application by its name, including path, with exception of applications that are in windows folder or in current active folder. But there are many alternatives to obtain application full path by reading the Windows Registry.
Jaime OlivaresSoftware ArchitectCommented:
Also read last section of this page (Controlling WinAMP from Visual Basic):
Shiju SasidharanAssoc Project ManagerCommented:
Try this
              ShellExecute 0, "Open", sPlaylists.Item(List1.ListIndex + 1), "/ADD", "", SW_SHOW


scanadminAuthor Commented:
cheerz surju.... i have tried that, doesnt seem to work!

jamie, willl try the registry thing - seems like the best option

thanks for all your help.
scanadminAuthor Commented:
for those of you who are interested i solved the problem like this

Dim sCommand As String
sCommand = ReadRegistry(HKEY_CLASSES_ROOT, "Applications\Winamp.exe\shell\Enqueue\command", "")
sCommand = Replace(sCommand, "%1", sPlaylists.Item(List1.ListIndex + 1))
WinExec sCommand, SW_SHOW

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.