我想在窗口注册表中注册我自己的项目扩展。我在谷歌上搜索,至少我找到了这段代码,效果很好,但我不明白一行。 “%L”是什么意思。
C#代码是
string ext = ".ext";
RegistryKey key = Registry.ClassesRoot.CreateSubKey(ext);
MessageBox.Show(exePath);
key.SetValue("", "My Project");
key.Close();
key = Registry.ClassesRoot.CreateSubKey(ext + "\\Shell\\Open\\command");
//key = key.CreateSubKey("command");
key.SetValue("", "\"" + Application.ExecutablePath + "\" \"%L\"");
key.Close();
key = Registry.ClassesRoot.CreateSubKey(ext + "\\DefaultIcon");
key.SetValue("", Application.StartupPath + "\\icon.ico");
key.Close();
那条线让我很困惑,
key.SetValue("", "\"" + Application.ExecutablePath + "\" \"%L\"");
请解释一下,我非常感谢你。
最佳答案
如果您的应用程序可执行文件位于 C:\your dir\your program.exe 该行被翻译成:
"C:\你的目录\你的程序.exe""%L"
%L 被翻译成你正在打开的文件,所以你的程序正在执行时将该文件作为第一个参数
关于c# - 在窗口注册表中注册文件扩展名?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1720710/