3 回答
TA贡献1712条经验 获得超3个赞
Raymond的文章:不要在托管代码中编写进程内Shell扩展。
最近的后续工作:.NET Framework版本4支持进程内并行运行时,现在可以在托管代码中编写Shell扩展了吗?
底线是,不,这不行:
已修订了实现进程内扩展的指南,并且继续建议不要在托管代码中编写shell扩展和Internet Explorer扩展(以及其他类型的进程内扩展),即使您使用的是版本4或更高版本。
TA贡献1802条经验 获得超5个赞
冒着风险,EZShellExtensions是用C#开发Shell扩展的绝佳(但非免费)框架。您可以编写一个简单的上下文菜单扩展,其中包含约20行代码,而且最重要的是,您不必再搞砸COM接口了。我公司将其(及其名称空间扩展框架)用于成千上万客户当前正在使用的一组扩展,并且就其价值而言,我们从未遇到上述CLR冲突的问题。
这是一个简单的示例,展示了它的简单性:
[Guid("00000000-0000-0000-0000-000000000000"), ComVisible(true)]
[TargetExtension(".txt", true)]
public class SampleExtension : ContextMenuExtension
{
protected override void OnGetMenuItems(GetMenuitemsEventArgs e)
{
e.Menu.AddItem("Sample Extension", "sampleverb", "Status/help text");
}
protected override bool OnExecuteMenuItem(ExecuteItemEventArgs e)
{
if (e.MenuItem.Verb == "sampleverb")
; // logic
return true;
}
[ComRegisterFunction]
public static void Register(Type t)
{
ContextMenuExtension.RegisterExtension(typeof(SampleExtension));
}
[ComUnregisterFunction]
public static void UnRegister(Type t)
{
ContextMenuExtension.UnRegisterExtension(typeof(SampleExtension));
}
}
- 3 回答
- 0 关注
- 764 浏览
添加回答
举报