Programmatically Add External Tools
-
Tuesday, October 18, 2005 2:04 PMIs there a way to programmatically add external tools to the Tools menu (or a customized menu item)? I'll be shipping an app which needs to be accessed through the Tools menu in VS2005 (or a cutom menu item), and during installation of the application I'd like to be able to create the necessary menu items in VS 2005.
Niels
Answers
-
Wednesday, November 02, 2005 2:08 AM
In addition to registering a tool for a particular user under HKCU\Software\Microsoft\VisualStudio\8.0\External Tools, it is also possible to register under HKLM\...\External Tools. If you register under HKLM, then the tool will be automatically installed for every user that uses Visual Studio on that machine. For your scenario this would probably be more convenient. The following is a simple test example that I tried:
Windows Registry Editor Version 5.00[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\8.0\External Tools\TestTool]
@=""
"ToolArg"="$(ItemPath)"
"ToolOpt"=dword:00000008
"ToolCmd"="notepad.exe"
"ToolDir"="$(TargetDir)"The flags that can be or'ed together in "ToolOpt" are the following:
#define TOOLOPT_ISAPPGUI 0x01
#define TOOLOPT_CLOSEONEXIT 0x02
#define TOOLOPT_PROMPTFORARGS 0x04
#define TOOLOPT_USEOUTPUTWIN 0x08
#define TOOLOPT_SAVEALLDOCS 0x10
#define TOOLOPT_USETASKLIST 0x20
#define TOOLOPT_UNICODE 0x40
All Replies
-
Wednesday, November 02, 2005 1:23 AMI'm afraid there's no built-in way to do this programmatically. The best option is to add registry entries under HKCU\Software\Microsoft\VisualStudio\8.0\External Tools (of course, the version number "8.0" will change in future versions). I recommend using regmon from www.sysinternals.com to monitor the registry changes that occur when you add the tool manually, then write code to perform the same changes.
Hope that helps.
-Josh -
Wednesday, November 02, 2005 2:08 AM
In addition to registering a tool for a particular user under HKCU\Software\Microsoft\VisualStudio\8.0\External Tools, it is also possible to register under HKLM\...\External Tools. If you register under HKLM, then the tool will be automatically installed for every user that uses Visual Studio on that machine. For your scenario this would probably be more convenient. The following is a simple test example that I tried:
Windows Registry Editor Version 5.00[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\8.0\External Tools\TestTool]
@=""
"ToolArg"="$(ItemPath)"
"ToolOpt"=dword:00000008
"ToolCmd"="notepad.exe"
"ToolDir"="$(TargetDir)"The flags that can be or'ed together in "ToolOpt" are the following:
#define TOOLOPT_ISAPPGUI 0x01
#define TOOLOPT_CLOSEONEXIT 0x02
#define TOOLOPT_PROMPTFORARGS 0x04
#define TOOLOPT_USEOUTPUTWIN 0x08
#define TOOLOPT_SAVEALLDOCS 0x10
#define TOOLOPT_USETASKLIST 0x20
#define TOOLOPT_UNICODE 0x40 -
Friday, November 25, 2005 8:10 AMThanks Douglas and Josh, I didn't see your replies - therefore my late thanks!
Niels

