How to add explorer right click menu item for my program?
I got a program with a listview in it, and I would like to know how to add files through explorer to my program, like select a bunch of files, right click one of them and add all the files to the listview (with files I mean full file names & paths). I need the general idea of this, am not asking for a copy-paste code, I need some guides as I don't know what to google for.
I know you add some registry keys somewhere in ClassesRoot, and maybe create some CLSID key which I don't know what it is, so anything related will be helpful.
Re: How to add explorer right click menu item for my program?
What's wrong with the OpenFileDialog? Or do yyou mean that you want to be able to right click on Explorer to open your application with the chosen files? In that case, here's your Google search.
Re: How to add explorer right click menu item for my program?
Quote:
Originally Posted by
dunfiddlin
What's wrong with the OpenFileDialog? Or do yyou mean that you want to be able to right click on Explorer to open your application with the chosen files? In that case,
here's your Google search.
Y, I meant the second one, and I'm looking into it right now. OpenFileDialog has been used already, as well as Drag & Drop, but I want the Explorer ContextMenuItem as well to make my app complete regarding methods of adding files to that listview.
Re: How to add explorer right click menu item for my program?
Ok, I made some progress, but still I'm not quite what I want to accomplish. My code is below, and it's very simple, but either I'm doing something wrong, or it is the wrong code for the job, or I need to add something. What it does is that for each file I selected it will open a new instance of my program with the respective file in the listview items. But I want all the items in one instance, and if my application is already open, don't create a new instance, but add the files to the listview.
I created my registrykey in ClassesRoot\*\shell\MyApp\command where I set the default value to "D:\Users\Legjendat\Documents\Visual Studio 2010\Projects\Test Project\Test Project\bin\Debug\Test Project.EXE "%1""
Any suggestions, or am I going the wrong way at it?
vb.net Code:
Public Sub AddFilesToListView(filePath As String)
ListView1.Items.Add(filePath)
End Sub
Public Sub Form1_load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If My.Application.CommandLineArgs.Count > 0 Then
AddFilesToListView(My.Application.CommandLineArgs(0))
Else
' 'If app is opened normally, do nothing.
End If
End Sub