tags:

views:

44

answers:

2

I have created 2 exe files: open.exe and edit.exe. and a new extension: say .newext.

Now I want to

  1. open by double click on .newext file with open exe.
  2. get a menu with right click on .newext file where in bold it is written "Open" and under that it is written "Edit". And by clicking "Edit" the edit.exe opens the .newext file.
  3. do this programmatically so that it could work on as much platforms as it is possible (at least on Xp, Vista, and Win7).

How I can achieve this?

+1  A: 

Take a look Here

beermann
A: 

You must edit the classes tree in the registry (using the registry functions from AdvApi32.dll). The following is not tested and off my head:

  • The base key is HKEY_LOCAL_MACHINE\Software\Classes for system-wide settings and HKEY_CURRENT_USER\Software\Classes for user-specific settings
  • In this base key, create a subkey with name .newext and default value X, where X is the class name (an arbitrary string that uniquely identifies the file type)
  • In the base key, create a subkey with name X and default value Y, where Y is the user-visible description of the file type
  • In the key X, create a subkey named shell with default value open
  • In the shell key, create a subkey named open with default value &Open
  • In the open key, create a subkey named command with default value "C:\path\to\open.exe" "%1"
  • In the shell key, create a subkey named edit with default value &Edit
  • In the edit key, create a subkey named command with default value "C:\path\to\edit.exe" "%1"
Philipp
What if it should work on linux as well?
Narek
On Linux the system is completely different and depends on the desktop environment (Gnome, KDE…). It might be better to start a new question for every desktop environment you plan to support (preferably on superuser.com since it's not really related to programming).
Philipp
Is this right for Vista???
Narek
Try it, I'm not sure and I don't have access to Vista.
Philipp