C#Windows的打开方式>'上下文菜单行为 [英] C# Windows 'Open With >' Context menu behaviour

查看:258
本文介绍了C#Windows的打开方式>'上下文菜单行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:结果
  与应用程序文件类型关联(C#)

我正在写一个C#Windows应用程序的可视化和修改.build文件(恶性脚本)。我想用户可以右键点击Windows资源管理器.build文件,并选择打开方式>选项,以使文件在我的应用程序进行修改。

I'm writing a C# Windows app to visualise and modify '.build' files (nant scripts). I would like the user to be able to right click on a .build file in windows explorer and select the 'Open With >' option to allow the file to be modified in my app.

什么是我的程序需要按顺序使用此机制合作,以支持?
什么可能我的程序需要做的到Windows,使上下文菜单支持?

What does my program need to support in-order to work with this mechanism? What might my program need to do to Windows to enable context menu support?

我想知道如果任何人都可以在这个问题的好文章/教程的方向指向了我。

I was wondering if anyone could point me in the direction of a good article/tutorial on this subject.

推荐答案

打开方式命令只传递文件作为第一个参数应用程序,所有你需要做的就是

The Open With command just passes the path of the file as the first argument to the application so all you need to do is

public static void Main(string[] args)
{
    if(args[0] != null)
    {
       //args[0] contans a path to the file do whatever you need to do to display it
    }
    else
    {
       //Start normally
    }
}

要全自动把你的程序在打开与列表中,您将需要在 HKEY_CLASSES_ROOT \\ YOUR_EXT \\ 添加一些章键。 <一href=\"http://stackoverflow.com/questions/212906/script-to-associate-an-extension-to-a-program#212921\">Here是一所以回答说如何做到这一点。

To automaticly put your program in the open with list you will need to add some reg keys in HKEY_CLASSES_ROOT\YOUR_EXT\. Here is a SO answer saying how to do it

或者您也可以手动添加到列表与开放的正常方式。

Or you could just add it by hand to the open with list the normal way.

这篇关于C#Windows的打开方式&GT;'上下文菜单行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆