4 Replies - 4362 Views - Last Post: 05 May 2012 - 07:32 AM Rate Topic: -----

#1 gymratz  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 129
  • Joined: 18-October 07

Stand Alone Application / Right Click Menu in Explorer

Posted 27 January 2011 - 02:23 PM

I'm hoping for a high level starting location for the following - as none of my searches are coming back (i'm probably not using the right terminology for anything).

I need to create an application that I can access by right clicking on a file and then choosing "Alter File" (Or whatever I call it). But I'm not even sure where to start - do I make it a console application? A form application? The end result is that the end user won't see anything but a prompt at the end letting them know if it was successful or if there was an error.

Again - any ideas on what to look for would be helpful... I'm normally a web guy!

Is This A Good Question/Topic? 0
  • +

Replies To: Stand Alone Application / Right Click Menu in Explorer

#2 Jack Eagles1  Icon User is offline

  • Pugnacious Penguin (inspired by no2pencil)
  • member icon

Reputation: 183
  • View blog
  • Posts: 1,152
  • Joined: 10-December 08

Re: Stand Alone Application / Right Click Menu in Explorer

Posted 27 January 2011 - 03:37 PM

Well, if you want to make your program the default for opening a certain file in windows explorer, I suggest you take a look at this article on CodeProject. It has the capacity to set your program as the default for opening files in Windows Explorer. When your program has been launched with parameters by Windows Explorer, you'll need to use Environment.GetCommandLineArgs (more on that here).

If you want to create your own contextmenuitem on windows explorer, I'd suggest looking into how they work (they use the Registry). You should be able to add certain values to the registry which will make Windows Explorer add an item on the right click menu (contextmenu) to launch your application. You'll then need to find the command lines which your program was started with, and tell your program to open the file which was pointed to when your program was launched.

Hope all of that made sense.
Was This Post Helpful? 1
  • +
  • -

#3 gymratz  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 129
  • Joined: 18-October 07

Re: Stand Alone Application / Right Click Menu in Explorer

Posted 28 January 2011 - 11:21 AM

It did all make sense, actually.
I was able to add a new context menu for .xlsx file types that when clicked will start a console application and passes in %L.
My console application then accesses the file name/location using command.tostring.

Everything is up and running! Thanks much!
Was This Post Helpful? 0
  • +
  • -

#4 azza = vb.pro  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 22-June 11

Re: Stand Alone Application / Right Click Menu in Explorer

Posted 05 May 2012 - 05:07 AM

is this what you want....?

you have a file. and a program. when the user goes to their my documents folder (or wherever this file is saved), and the user right-clicks on the file, they will see "modify this file" as an option. they click on it, and the file opens in your program for midification.

is this what you're looking for? if so (i don't know how to do it using code, that's what i'm trying to find out), then this is what you need to do:

first you need to program your application to read the command line argument that windows explorer will pass (when you right click a file click open with and select a program, it runs the program, and sends the path of the file to the program in the form of a command line argument. it will probably send the right-click command the user clicked as another argument). to add the command to the right-click menu (aka context menu) in windows explorer, i believe thats done in the registry. i believe you need to add a key to the HKEY_CLASSES_ROOT. the key will contain the information about the command, the program it will run, and the command line arguments it will pass (e.g. the file this command was used on and what command was clicked).

by the way, i forgot to mention that it doesn't matter if you use a windows forms application, class library, or a console application. the code is generally the same (sometimes you may have to import a few namespaces. in this case, it should just be the microsoft.win32 namespace to access registry)
Was This Post Helpful? 0
  • +
  • -

#5 sela007  Icon User is offline

  • D.I.C Addict

Reputation: 138
  • View blog
  • Posts: 838
  • Joined: 21-December 11

Re: Stand Alone Application / Right Click Menu in Explorer

Posted 05 May 2012 - 07:32 AM

Well, if you want to make your program the default for opening a certain file in windows explorer, I suggest you take a look at this article on CodeProject.

Hi Jack Eagles1! I've try this code, but this only works if extension not associated yet. For example if I want to open MP3s with my program ,it will not work because it's already associated with Winamp. It will only work for unassociated extensions. Do you know maybe how to solve that problem?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1