对VS2003插件进行深度研究

开发 后端
为每一个软件行业的从业人员,无论是开发人员、项目经理、还是测试人员,也要不断适应这个趋势,我认为VS 2003插件只会使我们的工作更简单和更轻松。

虽然有许多人对VS 2003插件的安全性表示怀疑,但在年复一年的不断发展中,他的安全性也在不断提高。保障VS 2003插件的安全性是完全有可能的,但前提是要深入理解到底什么是VS 2003插件,及他是怎么运作的。 #t#

选择"新建"->"项目"->"其他项目"->"Visual Studio.Net外接程序"创建一个C#的外接项目。默认地,会生成一个Connet.cs文件,该文件就是当你的Visual Studio 启动时加载的东西:好了,那么具体应该怎么写代码呢,看几个代码片断吧:

  1. object []contextGUIDS = new object[] { };   
  2. // 获得Visual Studio的Commands   
  3. Commands commands = applicationObject.Commands;   
  4. // 获得Visual Studio的菜单   
  5. _CommandBars commandBars = applicationObject.CommandBars;   
  6. try  
  7. {   
  8. // 获得Visual Studio的"工具"菜单   
  9. CommandBar toolsBar = (CommandBar)commandBars["Tools"];   
  10. foreach(CommandBarControl control in toolsBar.Controls)   
  11. {   
  12. // 如果VSX菜单已经存在就直接返回   
  13. if(control.Caption == "VSX")   
  14. {   
  15. return;  
  16. }   
  17. }   
  18. // 添加VSX菜单到工具栏下面   
  19. CommandBar vsxBar = (CommandBar)commands.AddCommandBar("VSX",vsCommandBarType.vsCommandBarTypeMenu,toolsBar,1);   
  20. // 添加OutLook到VSX菜单下面   
  21. Command command = commands.AddNamedCommand(addInInstance,"OutLook","打开OutLook","在VS中嵌入OutLook",true,50,ref contextGUIDS,(int)vsCommandStatus.vsCommandStatusSupported+(int)vsCommandStatus.vsCommandStatusEnabled);   
  22. command.AddControl(vsxBar,1);  
  23. }   
  24. catch(Exception ex)   
  25. {   
  26. System.Windows.Forms.MessageBox.Show(ex.ToString());   
  27. }  

看看VS 2003插件注释就知道干了些什么。首先获取"工具"菜单,然后在"工具"上面加了个"VSX",  ***在VSX上面加了个"OutLook". F5Debug一下,会弹出Visual Studio 2003,VS 2003插件看到工具下面的VSX没有?不过还没有任何功能。这里要注意的是:command.AddControl(vsxBar,1);就将command命令和vsxBar绑定在一起了。

责任编辑:chenqingxiang 来源: 新浪博客
相关推荐

2009-11-26 10:02:06

2009-12-01 17:55:11

VS2003配置

2009-12-18 10:10:49

VS 2003程序

2009-11-27 09:24:29

VS2003命令

2009-11-30 15:57:18

VS2003 MFC

2009-12-10 13:11:47

VS2003安装

2009-11-30 09:10:40

VS2003断点无效

2009-11-27 16:25:54

2009-11-26 09:42:38

VS2003插件

2009-11-26 10:18:59

VS2003学习

2009-12-09 13:41:04

VS 2003 报错

2009-11-25 11:25:31

VS2003软件

2009-11-25 15:39:24

VS2003 Incl

2009-12-01 14:04:17

VS2003 SP

2009-11-26 13:27:10

VS2003水晶报表

2009-11-27 08:59:29

VS2003配置文件

2009-11-30 13:51:28

VS2003 Runt

2009-11-25 14:17:35

VS2003打包

2009-11-25 10:48:29

VS2003调试

2009-11-30 09:27:38

VS2003源代码
点赞
收藏

51CTO技术栈公众号