views:

56

answers:

2

I have set .jpg file associated to my own program. I want to add the context menu to .jpg files, so I set the entry of HKCR.jpg\shell\open\command to "myProg.exe %1". After associating, there will be an item on the top of the context menu saying "Open image with myprog". This works right when I select a single .jpg file, but when I selected more than one file and click the top item of the context menu, nothing happended. How can I solve the problem?

Thank you very much

+1  A: 

Each selected file will be sent to a new instance of your application. Your application should check if a previous version exists, or not. If a previous instance exists, it should sent its parameters to it (e.g. using Windows Messages) and then terminate.

Another approach is to use DDE (Dynamic Data Exchange), an old method used by Shell to send all files to one instance of your program.

M. Jahedbozorgan
But when I select more than one files, no instance of my program was started at all.
quantity
Use double quotes around the %1.
M. Jahedbozorgan
I used double quotes,like this:"C:\\myProg.exe" "%1"What is wired is that it worked well when one file selected but failed when mutiple files selected. I don't know why.
quantity
When mutiple files are selected, is there an instance which does not receive the parameters, or there is no instance of your application at all?
M. Jahedbozorgan
When mutiple files are selected, there is no instance of my application at all.
quantity
A: 

You might need double quotes around the "%1".

Read this article for much more detailed information about how all this works. http://msdn.microsoft.com/en-us/library/bb776883.aspx

Also, this blog entry talks about what you need to do specifically for multi-select command execution: http://blogs.msdn.com/pix/archive/2006/06/30/652889.aspx

Alan McBee