1

I would like to write some code in Delphi for opening some files (e.g. mp3, png) with the associated program in Windows.

With AssocQueryString, I can find the program for a given extension. With this program, I can start the given file, when only one file was selected. The problem is when I try to start the program with a list of files.

Example 1 - mp3 is associated with AIMP3 and this call works fine

D:\Tools\AIMP3\AIMP3.exe "F:\TestFiles\mp3\file1.mp3" "F:\TestFiles\mp3\file2.mp3"

Example 2 - png is associated with IrfanView and this call fail

D:\Tools\IrfanView\i_view32.exe "F:\TestFiles\png\file1.png" "F:\TestFiles\png\file2.png"

IrfanView does not accept calling it with a list of files, but only with one file.

My question is, how do I find out if a program accepts as parameters just a single file or a list of files?

I have tried to check the Registry but found nothing. In shell->open->command I can find "%1" for both programs.

I have tried to use the IDropTarget interface, but this does not work with IrfanView, either (drop multiple files on i_view32.exe doesn't work in Windows Explorer, either).

On the other hand, Windows Explorer (if using Open from the context menu for many png files) opens a new instance of IrfanView for each file. If I had this information, I could also start IrfanView for each file.

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
Eric
  • 21
  • 3
  • You can't find this out in a generic way. There is no standard way for programs to indicate this. – David Heffernan Aug 09 '20 at 20:39
  • 1
    Short answer, unless the program is registered as a DropTarget or a DDE server, then Windows Explorer will launch a new process for each file selected. Programs may or may not act as singletons if they want to, delegating new processes to a master process if it is already running. – Remy Lebeau Aug 09 '20 at 21:19
  • Thanks for the answers. That helps me to keep looking for another solution. – Eric Aug 10 '20 at 19:18

0 Answers0