简体   繁体   中英

Passing selected multiple file names to the single instance of an exe file via Windows 10's Context menu

I have written a script in python 3.8 that takes two file names as command-line args and does some operations. And now I wish to add the .exe file of that script to Windows 10's context menu. I manually added an entry to the registry under "HKEY_CLASSES_ROOT*\\shell\\MY_APP\\command" but what it does is, execute the .exe file twice instead of taking them as multiple parameters to a single instance of my app.

Ask:

  1. How can I make it execute only once by-passing multiple selected file names as parameters to a single app instance?
  2. How can I build an installer that adds an entry to the registry automatically when the user is installing my app?

Thank you

The classic static verb registration you are doing here is always going to launch multiple instances.

There are two possible workarounds:

  • Implement IExplorerCommand orIDropTarget COM shell extensions.

  • When your application is started, try to find another instance already running and pass it the new path with some kind of IPC, for example the WM_COPYDATA message.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM