注册表 - .sdf 文件的 ContextMenu 扩展名 [英] Registry - ContextMenu extension of .sdf files

查看:35
本文介绍了注册表 - .sdf 文件的 ContextMenu 扩展名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想扩展 sdf 数据库文件的上下文菜单.我目前的来源

i want to extend the contextmenu of sdf database-files. my current source

    public static void Create()
    {
        string keyName = ".sdf";
        string contextName = "Das ist ein SDF Test";
        string exe = @"C:\Users\........exe";

        bool isWritable = true;

        try
        {
            RegistryKey classesRoot = Registry.ClassesRoot;
            RegistryKey parentKey = classesRoot.OpenSubKey(keyName, isWritable);

            parentKey.CreateSubKey("shell");

            RegistryKey shell = parentKey.OpenSubKey("shell", isWritable);
            RegistryKey context = shell.CreateSubKey(contextName);
            RegistryKey command = context.CreateSubKey("command");
            command.SetValue("", exe);
            classesRoot.Flush();
            classesRoot.Close();
        }
        catch (Exception)
        {
            throw;
        }
    }

现在,当我打开上下文菜单时,什么也没有发生......出了什么问题?

now, when i opened the contextmenu nothing is happened... what goes wrong?

推荐答案

根据您所说的,上下文菜单打开但没有任何反应,对吧?

Based on what you've said, the context menu opens but nothing happens, right?

如果是这种情况,您似乎需要将 .sdf 文件的完整路径传递到 exe 的命令行中.

If this is the case, it looks like you need to pass the full path of the .sdf file into your exe's command line.

因此将您的 exe 字符串变量更新为:

So update your exe string variable to be this:

string exe = @"\"C:\Users\........exe\" \"%1\"";

这会将 SDF 的完整路径传递给您的 exe.

which will pass in the full path to the SDF to your exe.

更新:

再研究一下,其实需要读取HKCR中.sdk的(默认)值.在我的机器上,它是Microsoft SQL Server Compact Edition 数据库文件".因此,您需要直接在 HKCR 下方创建一个新子项,并将您的 shell 和命令子项放在那里.查看 .txt.doc 以查看示例.

After researching again, you actually need to read the (default) value of .sdk in HKCR. On my machine it's "Microsoft SQL Server Compact Edition Database File". So you would need to create a new subkey directly below HKCR and and put your shell and command subkeys in there. Check out .txt and .doc to see an example.

这篇关于注册表 - .sdf 文件的 ContextMenu 扩展名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆