Results 1 to 4 of 4

Thread: Run multiple commands with ShellExecute

  1. #1
    Join Date
    Feb 2009
    Posts
    105

    Run multiple commands with ShellExecute

    Hello,

    I am developing a small application that should allow for (among others) to perform all actions on windows explorer files (actions that can be accessed by right clicking on a file in Explorer, for example " open "," edit ", etc).

    But I have a problem when it comes to open multiple files at the same time. In this case, I rely on the "Play in Winamp" on files. Mp3.

    In the registry, this action corresponds to the following:
    "C: \ Program Files \ Winamp \ winamp.exe" "% 1"
    % 1 is replaced by the file name.

    I am pretty sure that the windows explorer, when several are selected mp3, execute this command for each file. It then winamp which will in turn detect that it is executed several times within a time "very short" to create a single playlist with the files. (And not a single file in the playlist in the end, therefore, as the parameter "% 1" is always one of the selected files).

    I code my application in C #. At first I tried to parse the registry key, use Process.Start with winamp as a program and the name of a file as an argument (by repeating the call for all selected files).
    But problem # 1: it works, but the files are not in order in the playlist. This comes from the fact (I think) only when it starts another process, we have no control over scheduling, and thus the various winamp generated playlist in an unexpected order.

    Then I tried to use the ShellExecute (which comes from shell32.dll). I pass parameter in the "play" (as recorded in the register), and the name of a mp3 file path, and I called once per file.
    But problem # 2: I find myself in case the final winamp is open only with the last file in the list. Apparently ShellExecute waiting for the program switches to where he gets the message windows before returning, so take my winamp calls for separate calls (as if the mp3 was launched by hand one after the other: in the end it was more than the last file in the playlist).

    My question is to solve one of two problems: either pass to "order" creative process via successive calls to my Process.Start or succeed to use ShellExecute to start a list of files. I tried various methods of calling to enter path and not a file, but a list of file, but each time the method returns ShellExecute me a code 2 (file not found). What I have tested include:
    "file1" "file2" ...
    "file1" "file2", ...
    "file1" "file2"; ...

    I prefer to use the ShellExecute method, which is easier to generalize that Process.Start (because the parser registry keys may not function keys for a bit exotic).

    Thank you.

  2. #2
    Join Date
    Apr 2008
    Posts
    193

    Re: Run multiple commands with ShellExecute

    I wonder if there is a history of DDE there. And I do not know what level is taken into account by Explorer (this is taken into account by ShellExecute () or at the level above?)

  3. #3
    Join Date
    Feb 2009
    Posts
    105

    Re: Run multiple commands with ShellExecute

    DDE is to communicate with an application that is already launched and in the process of turning, right?
    Here it is to manage the launch winamp ... n times by running winamp.exe "file_x.mp3" of exploring the same way, so that winamp comes to correctly interpret and implement the n files in the playlist.
    I manage it at a level high enough, that's why I tried with the functions of shell32.dll. The only function that can run an application as ShellExecute. I did not find anything convincing about the functions DDE (but I know nothing to the DDE, I may have looked bad ...)

    Edit: and also apparently in response to DDE, the application must be coded for it ... which is certainly not true of all applications listed in the registry to run when you double click on a file.

  4. #4
    Join Date
    Apr 2008
    Posts
    193

    Re: Run multiple commands with ShellExecute

    What I meant was that I was not sure that Winamp is really launched X time, I thought instead of DDE conversations once launched Winamp (the method used for other programs). Unfortunately, I do not have Winamp on hand to check how exactly do its file associations.

Similar Threads

  1. Multiple commands for a batch file in a for loop?
    By SANDESH49 in forum Software Development
    Replies: 4
    Last Post: 08-05-2012, 10:40 AM
  2. Multiple commands in batch file loop
    By Toshaan in forum Vista Help
    Replies: 10
    Last Post: 08-05-2012, 10:39 AM
  3. MS-DOS help and commands
    By Kalyug in forum Operating Systems
    Replies: 8
    Last Post: 24-05-2011, 12:39 AM
  4. Need Basic Dos commands for Commands prompt
    By JangoRap in forum Operating Systems
    Replies: 5
    Last Post: 29-06-2009, 12:07 PM
  5. Replies: 3
    Last Post: 14-05-2009, 10:25 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,751,411,806.59523 seconds with 16 queries