返回首页

{A}简介
本文主要说明如何使用C#进行安装后创建一个Internet Explorer的上下文菜单项。通常这样的项目是不是独立的,并呼吁其他功能包括,但是这会显示一个创建一个分步指南。背景
首先,你需要了解如何手动添加一个Internet Explorer的上下文菜单项,和检查。创建项目
你这样一个项目的成分是:C#类库安装项目
C#类库,删除默认的类,右键点击项目名称,并单击"添加新项",然后选择安装程序类。
安装项目,只需要添加安装程序类项目的主要输出,输出到所有四个默认的自定义操作。 (右键单击安装项目名称,选择"查看GT;自定义操作。)
最后,您的解决方案应该看起来像这样:
非常简单化。现在我们只需要在安装项目进行调整处理代码前的一件事。基本上,我们需要获取用户在安装时提出的目标目录,要做到这一点。
选择下安装操作添加主输出,并在下面的图片中所描述的CustomActionData类型:创建安装程序类
安装程序的主要目的是创建注册表项,所以这里去:

//          

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Configuration.Install;

//DON'T FORGET TO ADD THIS ONE - used for the Registry Class

using Microsoft.Win32;



namespace IEContextInstallerClass

{

    [RunInstaller(true)]

    public partial class IEInstaller : Installer

    {

        public IEInstaller()

        {

            InitializeComponent();

        }



        public override void Install(System.Collections.IDictionary stateSaver)

        {

            base.Install(stateSaver);



            //grab the target director and add to install.installstate

            //note that the grabbed parameters are exactly the same 

            //as the one we set above

            stateSaver.Add("TargetDir", Context.Parameters["DP_TargetDir"].ToString());

        }



        public override void Commit(System.Collections.IDictionary savedState)

        {

            //retrieve the saved state

            base.Commit(savedState);

            //adding items to the context menu of IE

            RegistryKey key;

            //1,2,4,8,10,20 in heximal are 1,2,4,8,16,32 in decimal (respectively)

            string keyValueInt = "16";

            //the location of our key

            string subKey = 

        @"SOFTWARE\Microsoft\Internet Explorer\MenuExt\Sample Action";

            //create it

            key = Registry.CurrentUser.CreateSubKey(subKey);

            //set the value

            key.SetValue("Contexts", Convert.ToInt32(keyValueInt), 

                RegistryValueKind.DWord);

            //set the path to the action file

            key.SetValue(null, "file://" + savedState["TargetDir"].ToString() + 

                "\\action.html");

            //and close

            key.Close();

        }



        protected override void OnBeforeUninstall

            (System.Collections.IDictionary savedState)

        {

            base.OnBeforeUninstall(savedState);

            //removing items from the context menu of IE

            string subKey = 

        @"SOFTWARE\Microsoft\Internet Explorer\MenuExt\Sample Action";

            Registry.CurrentUser.DeleteSubKey(subKey);

        }

    }    

}

现在基本上安装程序类执​​行以下操作:安装后,抓住目标目录,并将其保存,所以我们可以使用在稍后阶段承诺后,创建注册表项情况下,用户希望卸载,只需删除键创建行动文件
这个动作文件是实际的代码,我们正在运行时单击上下文菜单上的:{C}
以上是一个简单的JavaScript获取选定的文本,它显示一个消息框... ...你可以有其他的行动,根据您的需要。 (上面的代码是基于{A5})。安装
一旦你完成了上述所有,建立自己的的解决方案,并安装。
你应该有以下项添加到您的注册表:{A6}
如果打开Internet Explorer的一个新实例,并用鼠标右键单击选定的文本,你应该得到:{A7}概括
所以基本上你现在应该能够创建和删除注册表项没有问题后,安装在所有。请注意
现在,这是绝对不创新或普通的东西,但我找不到类似的代码项目,因此我想加入。
此外,这是我发现一个项目汇编而"Googlingquot;在这里和那里...

回答

评论会员:Sosyopat 时间:2011/12/16
easly我们可以得到突出显示的文本,但我们如何才能得到图像的源时,它的点击

PS:对不起,我不好英语
评论会员:Dabara 时间:2011/12/16
您好
我想要得到的yahoomail收件箱的标题和我如何登录雅虎邮件,使用基于对话框的应用?我无法找到登录THA API Yhaoo邮件和Yahoo邮件的标题收件箱项目。

dabara