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?
If this is the case, it looks like you need to pass the full path of the
.sdffile into your exe’s command line.So update your exe string variable to be this:
which will pass in the full path to the
SDFto 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 belowHKCRand and put your shell and command subkeys in there. Check out.txtand.docto see an example.