I have created 2 exe files: open.exe and edit.exe. and a new extension: say .newext.
Now I want to
- open by double click on .newext file with open exe.
- 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.
- 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?
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 andHKEY_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 valueopen
- In the
shell
key, create a subkey namedopen
with default value&Open
- In the
open
key, create a subkey namedcommand
with default value"C:\path\to\open.exe" "%1"
- In the
shell
key, create a subkey namededit
with default value&Edit
- In the
edit
key, create a subkey namedcommand
with default value"C:\path\to\edit.exe" "%1"
精彩评论