Results 1 to 4 of 4

Thread: How to add explorer right click menu item for my program?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Apr 2010
    Posts
    131

    Question 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.
    Last edited by Legjendat; Jan 30th, 2013 at 04:18 PM.

  2. #2
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    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.
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Apr 2010
    Posts
    131

    Re: How to add explorer right click menu item for my program?

    Quote Originally Posted by dunfiddlin View Post
    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.

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Apr 2010
    Posts
    131

    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:
    1. Public Sub AddFilesToListView(filePath As String)
    2.        ListView1.Items.Add(filePath)
    3. End Sub
    4.  
    5.  Public Sub Form1_load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    6.  
    7.         If My.Application.CommandLineArgs.Count > 0 Then
    8.             AddFilesToListView(My.Application.CommandLineArgs(0))
    9.         Else
    10.             '    'If app is opened normally, do nothing.
    11.         End If
    12.  
    13. End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width