我想扩展sdf数据库文件的上下文菜单。 我现在的来源
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;
}
}
现在,当我打开上下文菜单时,什么也没发生...... 出了什么问题?
答案 0 :(得分:1)
根据你所说的,上下文菜单打开但没有任何反应,对吧?
如果是这种情况,您似乎需要将.sdf
文件的完整路径传递到exe的命令行。
所以将你的exe字符串变量更新为:
string exe = @"\"C:\Users\........exe\" \"%1\"";
将传递到SDF
到你的exe的完整路径。
<强>更新强>
再次研究之后,您实际上需要在HKCR
中读取.sdk的(默认)值。在我的机器上它是“Microsoft SQL Server Compact Edition数据库文件”。因此,您需要在HKCR
下方直接创建一个新子项,并将shell和命令子键放在那里。查看.txt
和.doc
以查看示例。