Solved

Right click on file or folder to launch app

Posted on 2002-05-22
7
189 Views
Last Modified: 2010-05-02
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.
0
Comment
Question by:zzconsumer
7 Comments
 
LVL 43

Expert Comment

by:TimCottee
Comment Utility
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.
0
 
LVL 43

Expert Comment

by:TimCottee
Comment Utility
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
0
 
LVL 1

Author Comment

by:zzconsumer
Comment Utility
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?
0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 28

Expert Comment

by:vinnyd79
Comment Utility
listening
0
 
LVL 43

Accepted Solution

by:
TimCottee earned 100 total points
Comment Utility
As for folders, I don't actually know but will look into it. Yes you do need to use a textbox, well two in fact because these are controls that support DDE functionality, one to send and one to receive the data. There may be other controls that support this as well but they don't necessarily have the required _Change event to handle new data - the label control is an example of this. I use two textboxes really to avoid confusion, I suppose that you could use just one and treat it as a sender in one instance and a receiver in the other.
0
 
LVL 1

Author Comment

by:zzconsumer
Comment Utility
That's it! Thanks a lot!
0
 
LVL 10

Expert Comment

by:arana
Comment Utility
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.
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now