问题
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?
回答1:
Based on what you've said, the context menu opens but nothing happens, right?
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.
So update your exe string variable to be this:
string exe = @"\"C:\Users\........exe\" \"%1\"";
which will pass in the full path to the SDF to your exe.
UPDATE:
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.
来源:https://stackoverflow.com/questions/8565521/registry-contextmenu-extension-of-sdf-files