Link to home
Start Free TrialLog in
Avatar of zzconsumer
zzconsumer

asked on

Right click on file or folder to launch app

Hi there,

I need to register all files and folders in Windows for a click on the right mouse button to open a context menu.

The program referred to in the context menu (the one I'm going to write) must get all selected files and folders as a parameter list when the user clicks the context menu entry. What can I do to achieve that? As I interprete from WinRAR's registry entries (I used that as my reference to find out a way to do it), i guess I need to write a COM+ object.

It's definately not enough for me to use HKEY_CLASSES_ROOT\*\shell\... for that because then my test program pops up once for each selected file. For folders, the registry entry does not work either. If you have a solution that way, you're welcome anyway.

So, if needed, where can I find REALLY good COM+ beginner's references and some easy-to-understand exampled? What's the best way to start with COM+?

Using C++ is not an option because my time is very, very limited and I'm really no C++ pro.
Avatar of TimCottee
TimCottee
Flag of United Kingdom of Great Britain and Northern Ireland image

zzconsumer, you can do it using the *\shell method in fact, what you have to do is to create a text box in your application that uses DDE. Set the form as a DDE source and then use App.PrevInstance to detect whether this is the first or a subsequent instance of the application, if it is the first then store the passed command line parameter, if a subsequent one then you use a DDE Poke to the original application to send the filename passed in as the command line parameter to the textbox. Then on the change event of this textbox add it to your list and terminate the subsequent instance, this way you end up with one instance that has a complete list of your selected files. I have a code sample somewhere that uses this method. I will dig it out and post it for you.
Here it is in its simple form, just change TDDE to the name of your executable, add two textboxes and set the form to be a DDE source.

Private Sub Form_Load()
  If App.PrevInstance Then
      Text2.LinkTopic = "TDDE|Form1"
      Text2.LinkItem = "Text1"
      Text2.LinkMode = vbLinkAutomatic
      Text2.Text = Command()
      Text2.LinkPoke
      End
  End If
End Sub

Private Sub Text1_Change()
  MsgBox Text1.Text
' Here you would add the new item to a list and / or process this filename.
End Sub
Avatar of zzconsumer
zzconsumer

ASKER

Thanks! There are still some things I'm wondering about:

Still belonging to the question:
Can I register folders the same or a similar way?

And just for interest:
Do I really need to use a Textbox?
Can you give a short explanation why I need two textboxes?
listening
ASKER CERTIFIED SOLUTION
Avatar of TimCottee
TimCottee
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
That's it! Thanks a lot!
Avatar of Arana (G.P.)
i did something similar, but in a different way,
i added a shortcut to the SENDTO folder, when the userclicks that shortcut, everything that were selected
passes as a parameter to the application referenced in the shortcut.

example:    test.bat shortcut is created in the sendto folder

test.exe contains:

Option Explicit
Sub Main()
MsgBox Command$
End Sub




when you select c:\command.com and right click and sendto test.bat

the msgbox is created with:
C:\command.com

if you select 2 folders and 1 file, the following is created

"C:\Documents and settings" C:\command.com C:\windows

quotes surround names with spaces on them.

you can then parse the command$ as you need it
this is an easy way to do what you want, but i dont know if it works this way when not called from the sendto.